<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/* Copyright 2011 MTA SZTAKI - Licensed under: GNU General Public License v2.0 or later */</span><span class="WHIT">
<span class='line'>  2</span> 
<span class='line'>  3</span> </span><span class="COMM">// Global object</span><span class="WHIT">
<span class='line'>  4</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  5</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>  6</span> 	 * @namespace Provides a toolbar for WikiEditor with tools to easily insert links, categories, references, etc.
<span class='line'>  7</span> 	 * @requires SztakipediaClient
<span class='line'>  8</span> 	 * @requires sztakipediaTemplate
<span class='line'>  9</span> 	 * @requires MediaWiki-UI
<span class='line'> 10</span> 	 * @requires jQuery
<span class='line'> 11</span> 	 * @public 
<span class='line'> 12</span> 	 */</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 15</span> 		 * All {@link sztakipediaTemplate} objects.
<span class='line'> 16</span> 		 * @field
<span class='line'> 17</span> 		 * @type Object
<span class='line'> 18</span> 		 * @name SztakipediaTB.Templates
<span class='line'> 19</span> 		 */</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">		</span><span class="STRN">"Templates"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 22</span> 		 * All dialogs.
<span class='line'> 23</span> 		 * @field
<span class='line'> 24</span> 		 * @type Object
<span class='line'> 25</span> 		 * @name SztakipediaTB.Dialogs
<span class='line'> 26</span> 		 */</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">		</span><span class="STRN">"Dialogs"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 28</span> 
<span class='line'> 29</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 30</span> 		 * Site-wide options that override {@link SztakipediaTB.DefaultOptions}, and are overidden by {@link SztakipediaTB.UserOptions}.
<span class='line'> 31</span> 		 * @field
<span class='line'> 32</span> 		 * @type Object
<span class='line'> 33</span> 		 * @name SztakipediaTB.Options
<span class='line'> 34</span> 		 */</span><span class="WHIT">		
<span class='line'> 35</span> 		</span><span class="STRN">"Options"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// Global options</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">		
<span class='line'> 37</span> 		</span><span class="COMM">/**
<span class='line'> 38</span> 		 * User options that override {@link SztakipediaTB.DefaultOptions} and {@link SztakipediaTB.Options}.
<span class='line'> 39</span> 		 * @field
<span class='line'> 40</span> 		 * @type Object
<span class='line'> 41</span> 		 * @name SztakipediaTB.UserOptions
<span class='line'> 42</span> 		 * @public
<span class='line'> 43</span> 		 */</span><span class="WHIT">		
<span class='line'> 44</span> 		</span><span class="STRN">"UserOptions"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// User options</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">		
<span class='line'> 46</span> 		</span><span class="COMM">/**
<span class='line'> 47</span> 		 * Global default options that are overidden by  {@link SztakipediaTB.Options} and by {@link SztakipediaTB.UserOptions}.
<span class='line'> 48</span> 		 * It mainly exist so the script won't break if a new option is added.
<span class='line'> 49</span> 		 * @field
<span class='line'> 50</span> 		 * @type Object
<span class='line'> 51</span> 		 * @name SztakipediaTB.DefaultOptions
<span class='line'> 52</span> 		 * @private
<span class='line'> 53</span> 		 */</span><span class="WHIT">				
<span class='line'> 54</span> 		</span><span class="STRN">"DefaultOptions"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// Script defaults</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">	</span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'SztakipediaTB'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// export name to be preserved</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">	
<span class='line'> 58</span> 	</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">		
<span class='line'> 60</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 61</span> 
<span class='line'> 62</span> </span><span class="COMM">//// JsonML (JSON => XML DOM) FIXME HACK</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="COMM">//importScriptURI('http://pediadev.sztaki.hu/~illes/SztakipediaToolbar/JsonML2.js');</span><span class="WHIT">
<span class='line'> 64</span> 
<span class='line'> 65</span> </span><span class="COMM">// only load on edit, unless its a user JS/CSS page</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">wgAction</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'edit'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">wgAction</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'submit'</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'> 67</span> 		</span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">wgNamespaceNumber</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">wgNamespaceNumber</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'> 68</span> 				</span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wgPageName.indexOf</span><span class="PUNC">(</span><span class="STRN">'.js'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">wgPageName.indexOf</span><span class="PUNC">(</span><span class="STRN">'.css'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 69</span> 
<span class='line'> 70</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-form-td {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"height: 0 !important;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding: 0.1em !important;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-form-td label {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding-left: 1.5em !important;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"white-space: nowrap;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-field-tooltip {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"color: navy;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-ref-preview {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"font-family: monospace;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-ref-preview, .sztakipedia-preview-parsed {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding: 0em 1em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-widget {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"font-size: 0.75em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">	
<span class='line'> 76</span> 	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"max-height: 90%;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">	
<span class='line'> 77</span> 	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"overflow: hidden;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content input {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding:4px 2px;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"border:solid 1px #aacfe4;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-info-id {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"font-weight: bold;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-dialogs, .sztakipedia-form-container {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"display: block;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"height: 350px;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"overflow: auto;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"margin: 2px;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-dialog-block {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"display: block;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"border: 1px solid #AED0EA;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"background-color: white;"</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"margin-bottom: 0.5em;"</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">			</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding: 0.2em 0.2em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-search-form {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"display: block;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"border: 1px solid #AED0EA;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"background-color: #EEE;"</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"margin-bottom: 0.5em;"</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">			</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding: 0.2em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding-right: 0.5em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">"input.sztakipedia-checkbox, label.sztakipedia-checkbox {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"vertical-align: middle;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">	
<span class='line'> 87</span> 	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-dialog-block ul li {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"list-style: none outside none;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"margin: 8px;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content ul {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"margin: 0px;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding: 0px;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">	
<span class='line'> 90</span> 	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-container {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"width: 95%;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"overflow: hidden;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://www.quirksmode.org/css/clearing.html</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-text-container {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"float: left;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"width: 85%;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/*border: 1px dotted red;*/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://www.quirksmode.org/css/clearing.html</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-image-container {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"float: right;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"width: 10%;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/*border: 1px dotted red;*/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://www.quirksmode.org/css/clearing.html</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">	
<span class='line'> 94</span> 	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-image-container {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding-right: 0.2em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">	
<span class='line'> 96</span> 	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-text {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"color: #0645AD;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"font-size: 120%;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-meta {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"color: #0E774A;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"display: block;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-snippet {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"color: black;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"display: block;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding-top: 0.1em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-snippet b {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"background-color: #FFCCCC;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding: 0em 0.2em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content img.sztakipedia-suggestion-thumbnail {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"background-color: white;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/*border: 1px solid #0645AD;*/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding: 1px;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"width: 40px;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-actions {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"display: block;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"padding-top: .1em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-action {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"color: #3366CC;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"opacity: .30;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"text-decoration: none;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"margin-right: 1em;"</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-action-title {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"text-decoration: underline;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"margin-left: .2em;"</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-suggestion-action:hover {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"opacity: 1;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">	</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content .sztakipedia-dialog-block-title, .sztakipedia-prev-parsed-label, .sztakipedia-preview-label {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"font-weight: bold;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">  </span><span class="STRN">"margin-bottom: 0.3em;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> 
<span class='line'>107</span> </span><span class="WHIT">	</span><span class="COMM">//appendCSS('.ui-dialog-content input.non-empty {' +"background-color: red;" + "}"); TODO fix higlighting of non.empty fields</span><span class="WHIT">
<span class='line'>108</span> 
<span class='line'>109</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.DefaultOptions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">		</span><span class="STRN">"date format"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"&lt;year>-&lt;zmonth>-&lt;zdate>"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">		</span><span class="STRN">"autodate fields"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">		</span><span class="STRN">"months"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="STRN">'Jan'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Feb'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Mar'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Apr'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'May'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Jun'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Jul'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Aug'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Sep'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Oct'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Nov'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Dec'</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">		</span><span class="STRN">"modal"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">		</span><span class="STRN">"autoparse"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">		</span><span class="STRN">"expandtemplates"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">		</span><span class="STRN">"debug"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">		</span><span class="STRN">"basedir"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"http://pediadev.sztaki.hu/~illes/SztakipediaToolbar/"</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB</span><span class="PUNC">[</span><span class="STRN">'DefaultOptions'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.DefaultOptions</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// export name for Closure </span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">	
<span class='line'>121</span> 	</span><span class="COMM">/**
<span class='line'>122</span> 	 * Get an option - user settings override site-wide which override defaults.
<span class='line'>123</span> 	 * @param {string|undefined} opt The name of the option.
<span class='line'>124</span> 	 * @return {string} The value of the option.
<span class='line'>125</span> 	 */</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.getOption</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">opt</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.UserOptions</span><span class="PUNC">[</span><span class="NAME">opt</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.UserOptions</span><span class="PUNC">[</span><span class="NAME">opt</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.Options</span><span class="PUNC">[</span><span class="NAME">opt</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.Options</span><span class="PUNC">[</span><span class="NAME">opt</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.DefaultOptions</span><span class="PUNC">[</span><span class="NAME">opt</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> 
<span class='line'>136</span> 
<span class='line'>137</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>138</span> 	 * The textarea to attach to.
<span class='line'>139</span> 	 * @return {jQuery|wikiEditor} The jQuery DOM element of the main text input field.
<span class='line'>140</span> 	 */</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.getTarget</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#wpTextbox1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> 
<span class='line'>145</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>146</span> 	 * Create a WikiEditor dialog from a {@link sztakipediaTemplate} object.
<span class='line'>147</span> 	 * @param {Object} tem The {@link sztakipediaTemplate} object to create a dialog for.
<span class='line'>148</span> 	 * @return {Object} A WikiEditor-style dialog descriptor.  
<span class='line'>149</span> 	 */</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.toDialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">tem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sform</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">tem.shortform</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogid</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sform</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">			</span><span class="NAME">resizeme</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">			</span><span class="NAME">titleMsg</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">dialogid</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">			</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sform</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">			</span><span class="NAME">init</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">			</span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">tem.getInitial</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">			</span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">				</span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">675</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">				</span><span class="NAME">open</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">					</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getForm</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">					</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-prev-parse'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="STRN">'click'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.prevParseClick</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">				</span><span class="NAME">beforeclose</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">					</span><span class="NAME">SztakipediaTB.resetForm</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">				</span><span class="NAME">buttons</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">					</span><span class="STRN">'sztakipedia-form-submit'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">						</span><span class="NAME">$j.wikiEditor.modules.toolbar.fn.doAction</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">data</span><span class="PUNC">(</span><span class="STRN">'context'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">							</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'encapsulate'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">							</span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">								</span><span class="NAME">peri</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">							</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT">						</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ref</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getRef</span><span class="PUNC">(</span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">						</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">						</span><span class="NAME">$j.wikiEditor.modules.toolbar.fn.doAction</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">data</span><span class="PUNC">(</span><span class="STRN">'context'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">							</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'encapsulate'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">							</span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">								</span><span class="NAME">pre</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">ref</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">							</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">					</span><span class="STRN">'sztakipedia-form-showhide'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.showHideExtra</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">					</span><span class="STRN">'wikieditor-toolbar-tool-link-cancel'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">						</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">					</span><span class="STRN">'sztakipedia-form-reset'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">						</span><span class="NAME">SztakipediaTB.resetForm</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">		
<span class='line'>197</span> 		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tem.preview</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">			</span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'dialog'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'buttons'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'sztakipedia-refpreview'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ref</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getRef</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">template.refs</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">div</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">"#sztakipediatoolbar-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sform</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">				</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-preview-label'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">show</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">				</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-ref-preview'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">ref</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">show</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">				
<span class='line'>205</span> 				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">container</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-form-container'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT">	</span><span class="NAME">scrollTo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-ref-preview'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>207</span> 
<span class='line'>208</span> </span><span class="WHIT">	
<span class='line'>209</span> 				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'autoparse'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">					</span><span class="NAME">SztakipediaTB.scrollTo</span><span class="PUNC">(</span><span class="NAME">scrollTo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">container</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">					</span><span class="NAME">SztakipediaTB.prevParseClick</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">				</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">					</span><span class="NAME">SztakipediaTB.scrollTo</span><span class="PUNC">(</span><span class="NAME">scrollTo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">container</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'fast'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">					
<span class='line'>216</span> 					</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-prev-parse'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">show</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">					</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-prev-parsed-label'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">					</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-preview-parsed'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>223</span> 
<span class='line'>224</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>225</span> 	 * Initialize the book reference insertion tool.
<span class='line'>226</span> 	 * @private
<span class='line'>227</span> 	 */</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.initBook</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>229</span> 
<span class='line'>230</span> </span><span class="WHIT">		</span><span class="COMM">// Add dialog</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bookDialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">			</span><span class="STRN">'sztakipedia-toolbar-dialog-bookprediction'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">				</span><span class="NAME">titleMsg</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-bookprediction-title'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">				</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-bookprediction'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">				</span><span class="NAME">resizeme</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">				</span><span class="NAME">init</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">				</span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">					</span><span class="STRN">'&lt;div id="sztakipediatoolbar-dialog-bookprediction-form"/>'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">					</span><span class="STRN">'&lt;div id="sztakipediatoolbar-dialog-bookprediction-content" class="sztakipedia-dialogs">'</span><span class="WHIT"> 
<span class='line'>241</span> 						</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="sztakipedia-dialog-bookprediction-loading">'</span><span class="WHIT"> 
<span class='line'>242</span> 						</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'</span><span class="WHIT"> 
<span class='line'>243</span> 						</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&nbsp;'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-loading'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">						</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">				</span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">					</span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">550</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">					</span><span class="NAME">open</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">						</span><span class="NAME">SztakipediaTB.loadBookSuggestions</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">					</span><span class="NAME">buttons</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">						</span><span class="STRN">'sztakipedia-search-form-submit'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.handleBookFormSubmit</span><span class="PUNC">,</span><span class="WHIT">		
<span class='line'>252</span> 						</span><span class="STRN">'sztakipedia-form-showhide'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.showHideExtra</span><span class="PUNC">,</span><span class="WHIT">						
<span class='line'>253</span> 						</span><span class="STRN">'wikieditor-toolbar-tool-link-cancel'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">							</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">						</span><span class="STRN">'sztakipedia-form-reset'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">							</span><span class="NAME">SztakipediaTB.resetForm</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="WHIT">						
<span class='line'>259</span> 					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addDialog'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bookDialog</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> 
<span class='line'>265</span> </span><span class="WHIT">		</span><span class="COMM">// To add a button to an existing toolbar group:        </span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addToToolbar'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">			</span><span class="STRN">'section'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedias'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">			</span><span class="STRN">'group'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'suggestions'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">			</span><span class="STRN">'tools'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">				</span><span class="STRN">'bookprediction'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">					</span><span class="NAME">label</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Book'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">					</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'button'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">					</span><span class="NAME">icon</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Nuvola_apps_bookcase.svg/22px-Nuvola_apps_bookcase.svg.png'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">					</span><span class="COMM">//					action : {</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">					</span><span class="COMM">//						type : 'callback',</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">					</span><span class="COMM">//						execute : function(context) {</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">					</span><span class="COMM">//							alert('remove');</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">					</span><span class="COMM">//							SztakipediaTB.target.wikiEditor('removeFromToolbar', {</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">					</span><span class="COMM">//								'section' : 'sztakipedias',</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">					</span><span class="COMM">//								'group' : 'suggestions',</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">					</span><span class="COMM">//								'tool' : 'book'</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">					</span><span class="COMM">//							});</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">					</span><span class="COMM">//						}</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">					</span><span class="COMM">//					},</span><span class="WHIT">
<span class='line'>285</span> 
<span class='line'>286</span> </span><span class="WHIT">					</span><span class="COMM">//					action : {</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">					</span><span class="COMM">//						type : 'encapsulate',</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">					</span><span class="COMM">//						options : {</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">					</span><span class="COMM">//							pre : "{{cite book}}" // text to be inserted</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">					</span><span class="COMM">//					}</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">					</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">						</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'dialog'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">						</span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-toolbar-dialog-bookprediction'</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>299</span> 
<span class='line'>300</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>301</span> 	 * Initialize the internal link insertion tool.
<span class='line'>302</span> 	 * @private
<span class='line'>303</span> 	 */</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.initLink</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>305</span> 
<span class='line'>306</span> </span><span class="WHIT">		</span><span class="COMM">// Add dialog</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">linkDialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">			</span><span class="STRN">'sztakipedia-toolbar-dialog-link'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">				</span><span class="NAME">titleMsg</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-link-title'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">				</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-link'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">				</span><span class="NAME">resizeme</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">				</span><span class="NAME">init</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">				</span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="sztakipediatoolbar-dialog-link-content" class="sztakipedia-dialogs">'</span><span class="WHIT"> 
<span class='line'>315</span> 					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="sztakipedia-dialog-link-loading">'</span><span class="WHIT"> 
<span class='line'>316</span> 					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'</span><span class="WHIT"> 
<span class='line'>317</span> 					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&nbsp;'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-loading'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT">				</span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>320</span> </span><span class="WHIT">					</span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">550</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">					</span><span class="NAME">open</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">						</span><span class="NAME">SztakipediaTB.loadLinkSuggestions</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>323</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>324</span> </span><span class="WHIT">					</span><span class="NAME">buttons</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">						</span><span class="STRN">'wikieditor-toolbar-tool-link-cancel'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">							</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>327</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>329</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>330</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>331</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>332</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addDialog'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">linkDialog</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>333</span> 
<span class='line'>334</span> </span><span class="WHIT">		</span><span class="COMM">//		// FIXME for testing</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">		</span><span class="COMM">//		// To add a group to an existing toolbar section:</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT">		</span><span class="COMM">//		SztakipediaTB.getTarget().wikiEditor('addToToolbar', {</span><span class="WHIT">
<span class='line'>337</span> </span><span class="WHIT">		</span><span class="COMM">//			'section' : 'sztakipedias',</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">		</span><span class="COMM">//			'groups' : {</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">		</span><span class="COMM">//				'suggestions' : {</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">		</span><span class="COMM">//					'label' : 'Suggestions' // FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">		</span><span class="COMM">//				}</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">		</span><span class="COMM">//			}</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">		</span><span class="COMM">//			});</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">		</span><span class="COMM">// To add a button to an existing toolbar group:        </span><span class="WHIT">
<span class='line'>345</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addToToolbar'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">			</span><span class="STRN">'section'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedias'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>347</span> </span><span class="WHIT">			</span><span class="STRN">'group'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'suggestions'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">			</span><span class="STRN">'tools'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>349</span> </span><span class="WHIT">				</span><span class="STRN">'link'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT">					</span><span class="NAME">label</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Internal link'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT">					</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'button'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">					</span><span class="NAME">icon</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'http://svn.wikimedia.org/svnroot/mediawiki/branches/wmf-deployment/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-ilink.png'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">					</span><span class="COMM">//					action : {</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">					</span><span class="COMM">//						type : 'callback',</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT">					</span><span class="COMM">//						execute : function(context) {</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">					</span><span class="COMM">//							alert('remove');</span><span class="WHIT">
<span class='line'>357</span> </span><span class="WHIT">					</span><span class="COMM">//							SztakipediaTB.target.wikiEditor('removeFromToolbar', {</span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">					</span><span class="COMM">//								'section' : 'sztakipedias',</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">					</span><span class="COMM">//								'group' : 'suggestions',</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">					</span><span class="COMM">//								'tool' : 'book'</span><span class="WHIT">
<span class='line'>361</span> </span><span class="WHIT">					</span><span class="COMM">//							});</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">					</span><span class="COMM">//						}</span><span class="WHIT">
<span class='line'>363</span> </span><span class="WHIT">					</span><span class="COMM">//					},</span><span class="WHIT">
<span class='line'>364</span> </span><span class="WHIT">					</span><span class="COMM">//					action : {</span><span class="WHIT">
<span class='line'>365</span> </span><span class="WHIT">					</span><span class="COMM">//						type : 'encapsulate',</span><span class="WHIT">
<span class='line'>366</span> </span><span class="WHIT">					</span><span class="COMM">//						options : {</span><span class="WHIT">
<span class='line'>367</span> </span><span class="WHIT">					</span><span class="COMM">//							pre : "{{cite book}}" // text to be inserted</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">					</span><span class="COMM">//					}</span><span class="WHIT">
<span class='line'>369</span> </span><span class="WHIT">					</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT">						</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'dialog'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">						</span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-toolbar-dialog-link'</span><span class="WHIT">
<span class='line'>372</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>377</span> 
<span class='line'>378</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>379</span> 	 * Initialize the category link insertion tool.
<span class='line'>380</span> 	 * @private
<span class='line'>381</span> 	 */</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.initCategory</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>383</span> 
<span class='line'>384</span> </span><span class="WHIT">		</span><span class="COMM">// Add dialog</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">catDialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">			</span><span class="STRN">'sztakipedia-toolbar-dialog-category'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">				</span><span class="NAME">titleMsg</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-category-title'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">				</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-category'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>389</span> </span><span class="WHIT">				</span><span class="NAME">resizeme</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT">				</span><span class="NAME">init</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">				</span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="sztakipedia-dialog-category-loading">'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&nbsp;'</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">						</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-loading'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">				</span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">					</span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">550</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">					</span><span class="NAME">open</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">						</span><span class="NAME">SztakipediaTB.loadCategorySuggestions</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">					</span><span class="NAME">buttons</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">						</span><span class="STRN">'wikieditor-toolbar-tool-link-cancel'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">							</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>403</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>407</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addDialog'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">catDialog</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>408</span> 
<span class='line'>409</span> </span><span class="WHIT">		</span><span class="COMM">// To add a button to an existing toolbar group:        </span><span class="WHIT">
<span class='line'>410</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addToToolbar'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>411</span> </span><span class="WHIT">			</span><span class="STRN">'section'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedias'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>412</span> </span><span class="WHIT">			</span><span class="STRN">'group'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'suggestions'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>413</span> </span><span class="WHIT">			</span><span class="STRN">'tools'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>414</span> </span><span class="WHIT">				</span><span class="STRN">'category'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>415</span> </span><span class="WHIT">					</span><span class="NAME">label</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Category'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>416</span> </span><span class="WHIT">					</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'button'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT">					</span><span class="NAME">icon</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">//'http://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/Nuvola_filesystems_folder_cyan.png/22px-Nuvola_filesystems_folder_cyan.png', </span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT">						</span><span class="COMM">//'http://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Venn_diagram_coloured.svg/22px-Venn_diagram_coloured.svg.png',</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT">					</span><span class="COMM">//'http://upload.wikimedia.org/wikipedia/commons/thumb/9/9c/Categorisation-hierarchy-top2down.svg/22px-Categorisation-hierarchy-top2down.svg.png', </span><span class="WHIT">
<span class='line'>420</span> </span><span class="COMM">//					'http://upload.wikimedia.org/wikipedia/commons/thumb/5/55/Nuvola_apps_katomic.svg/22px-Nuvola_apps_katomic.svg.png',</span><span class="WHIT">
<span class='line'>421</span> </span><span class="WHIT">					</span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/9/92/Nuvola_apps_ipo.svg/22px-Nuvola_apps_ipo.svg.png'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT">					</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">						</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'dialog'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">						</span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-toolbar-dialog-category'</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>430</span> 
<span class='line'>431</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>432</span> 	 * Initialize the infobox insertion tool.
<span class='line'>433</span> 	 * @private
<span class='line'>434</span> 	 */</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.initInfobox</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT">		</span><span class="COMM">// Add dialog</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">infoboxDialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT">			</span><span class="STRN">'sztakipedia-toolbar-dialog-infobox'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>439</span> </span><span class="WHIT">				</span><span class="NAME">titleMsg</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-infobox-title'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>440</span> </span><span class="WHIT">				</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-infobox'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>441</span> </span><span class="WHIT">				</span><span class="NAME">resizeme</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT">				</span><span class="NAME">init</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>444</span> </span><span class="WHIT">				</span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="sztakipediatoolbar-dialog-infobox-content" class="sztakipedia-dialogs">'</span><span class="WHIT"> 
<span class='line'>445</span> 					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="sztakipedia-dialog-infobox-loading">'</span><span class="WHIT"> 
<span class='line'>446</span> 					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'</span><span class="WHIT"> 
<span class='line'>447</span> 					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&nbsp;'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-loading'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT">					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>449</span> </span><span class="WHIT">				</span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>450</span> </span><span class="WHIT">					</span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">550</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>451</span> </span><span class="WHIT">					</span><span class="NAME">open</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT">						</span><span class="NAME">SztakipediaTB.loadInfoboxSuggestions</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>453</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">					</span><span class="NAME">buttons</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>455</span> </span><span class="WHIT">						</span><span class="STRN">'wikieditor-toolbar-tool-link-cancel'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT">							</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>457</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addDialog'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">infoboxDialog</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>463</span> 
<span class='line'>464</span> </span><span class="WHIT">		</span><span class="COMM">// To add a button to an existing toolbar group:        </span><span class="WHIT">
<span class='line'>465</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addToToolbar'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">			</span><span class="STRN">'section'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedias'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">			</span><span class="STRN">'group'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'suggestions'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT">			</span><span class="STRN">'tools'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">				</span><span class="STRN">'infobox'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT">					</span><span class="NAME">label</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Infobox'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>471</span> </span><span class="WHIT">					</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'button'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>472</span> </span><span class="WHIT">					</span><span class="NAME">icon</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Application-default-icon.svg/22px-Application-default-icon.svg.png'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT">					</span><span class="COMM">//'http://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/Taxobox_example.png/22px-Taxobox_example.png',</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT">					</span><span class="COMM">//'http://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/Gnome-insert-object.svg/22px-Gnome-insert-object.svg.png',</span><span class="WHIT">
<span class='line'>475</span> </span><span class="WHIT">					</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>476</span> </span><span class="WHIT">						</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'dialog'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>477</span> </span><span class="WHIT">						</span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-toolbar-dialog-infobox'</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>480</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>481</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">			
<span class='line'>483</span> 
<span class='line'>484</span> 	</span><span class="COMM">/**
<span class='line'>485</span> 	 * Initialize the toolbar for debugging tools.
<span class='line'>486</span> 	 * @private
<span class='line'>487</span> 	 */</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.initInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>489</span> 
<span class='line'>490</span> </span><span class="WHIT">		</span><span class="COMM">// Add dialog</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">infoDialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT">			</span><span class="STRN">'sztakipedia-toolbar-dialog-info'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">				</span><span class="NAME">titleMsg</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-info-title'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>494</span> </span><span class="WHIT">				</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-info'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT">				</span><span class="NAME">resizeme</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT">				</span><span class="NAME">init</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT">				</span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="sztakipedia-dialog-info-loading">'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&nbsp;'</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT">						</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-loading'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>500</span> </span><span class="WHIT">				</span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">					</span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">550</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">					</span><span class="NAME">open</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT">						</span><span class="NAME">SztakipediaTB.setupInfo</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT">					</span><span class="NAME">buttons</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT">						</span><span class="STRN">'wikieditor-toolbar-tool-link-cancel'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT">							</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>508</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>509</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>510</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>511</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>512</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addDialog'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">infoDialog</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>514</span> 
<span class='line'>515</span> </span><span class="WHIT">		</span><span class="COMM">// To add a group to an existing toolbar section:</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addToToolbar'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>517</span> </span><span class="WHIT">			</span><span class="STRN">'section'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedias'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT">			</span><span class="STRN">'groups'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT">				</span><span class="STRN">'debug'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT">					</span><span class="STRN">'label'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Debug'</span><span class="WHIT"> </span><span class="COMM">// FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT">		</span><span class="COMM">// To add a button to an existing toolbar group:        </span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addToToolbar'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT">			</span><span class="STRN">'section'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedias'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT">			</span><span class="STRN">'group'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'debug'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT">			</span><span class="STRN">'tools'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>529</span> </span><span class="WHIT">				</span><span class="STRN">'info'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT">					</span><span class="NAME">label</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Info'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>531</span> </span><span class="WHIT">					</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'button'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>532</span> </span><span class="WHIT">					</span><span class="NAME">icon</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Gtk-dialog-info.svg/22px-Gtk-dialog-info.svg.png'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>533</span> </span><span class="WHIT">					</span><span class="COMM">//					action : {</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT">					</span><span class="COMM">//						type : 'callback',</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT">					</span><span class="COMM">//						execute : function(context) {</span><span class="WHIT">
<span class='line'>536</span> </span><span class="WHIT">					</span><span class="COMM">//							alert('remove');</span><span class="WHIT">
<span class='line'>537</span> </span><span class="WHIT">					</span><span class="COMM">//							SztakipediaTB.target.wikiEditor('removeFromToolbar', {</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT">					</span><span class="COMM">//								'section' : 'sztakipedias',</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT">					</span><span class="COMM">//								'group' : 'suggestions',</span><span class="WHIT">
<span class='line'>540</span> </span><span class="WHIT">					</span><span class="COMM">//								'tool' : 'book'</span><span class="WHIT">
<span class='line'>541</span> </span><span class="WHIT">					</span><span class="COMM">//							});</span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT">					</span><span class="COMM">//						}</span><span class="WHIT">
<span class='line'>543</span> </span><span class="WHIT">					</span><span class="COMM">//					},</span><span class="WHIT">
<span class='line'>544</span> 
<span class='line'>545</span> </span><span class="WHIT">					</span><span class="COMM">//					action : {</span><span class="WHIT">
<span class='line'>546</span> </span><span class="WHIT">					</span><span class="COMM">//						type : 'encapsulate',</span><span class="WHIT">
<span class='line'>547</span> </span><span class="WHIT">					</span><span class="COMM">//						options : {</span><span class="WHIT">
<span class='line'>548</span> </span><span class="WHIT">					</span><span class="COMM">//							pre : "{{cite book}}" // text to be inserted</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT">					</span><span class="COMM">//					}</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT">					</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>551</span> </span><span class="WHIT">						</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'dialog'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>552</span> </span><span class="WHIT">						</span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-toolbar-dialog-info'</span><span class="WHIT">
<span class='line'>553</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>554</span> 
<span class='line'>555</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>556</span> </span><span class="WHIT">				</span><span class="STRN">'update'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>557</span> </span><span class="WHIT">					</span><span class="NAME">label</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Update'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>558</span> </span><span class="WHIT">					</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'button'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>559</span> </span><span class="WHIT">					</span><span class="NAME">icon</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Gnome-view-refresh.svg/22px-Gnome-view-refresh.svg.png'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>560</span> </span><span class="WHIT">					</span><span class="COMM">//					action : {</span><span class="WHIT">
<span class='line'>561</span> </span><span class="WHIT">					</span><span class="COMM">//						type : 'callback',</span><span class="WHIT">
<span class='line'>562</span> </span><span class="WHIT">					</span><span class="COMM">//						execute : function(context) {</span><span class="WHIT">
<span class='line'>563</span> </span><span class="WHIT">					</span><span class="COMM">//							alert('remove');</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT">					</span><span class="COMM">//							SztakipediaTB.target.wikiEditor('removeFromToolbar', {</span><span class="WHIT">
<span class='line'>565</span> </span><span class="WHIT">					</span><span class="COMM">//								'section' : 'sztakipedias',</span><span class="WHIT">
<span class='line'>566</span> </span><span class="WHIT">					</span><span class="COMM">//								'group' : 'suggestions',</span><span class="WHIT">
<span class='line'>567</span> </span><span class="WHIT">					</span><span class="COMM">//								'tool' : 'book'</span><span class="WHIT">
<span class='line'>568</span> </span><span class="WHIT">					</span><span class="COMM">//							});</span><span class="WHIT">
<span class='line'>569</span> </span><span class="WHIT">					</span><span class="COMM">//						}</span><span class="WHIT">
<span class='line'>570</span> </span><span class="WHIT">					</span><span class="COMM">//					},</span><span class="WHIT">
<span class='line'>571</span> 
<span class='line'>572</span> </span><span class="WHIT">					</span><span class="COMM">//					action : {</span><span class="WHIT">
<span class='line'>573</span> </span><span class="WHIT">					</span><span class="COMM">//						type : 'encapsulate',</span><span class="WHIT">
<span class='line'>574</span> </span><span class="WHIT">					</span><span class="COMM">//						options : {</span><span class="WHIT">
<span class='line'>575</span> </span><span class="WHIT">					</span><span class="COMM">//							pre : "{{cite book}}" // text to be inserted</span><span class="WHIT">
<span class='line'>576</span> </span><span class="WHIT">					</span><span class="COMM">//					}</span><span class="WHIT">
<span class='line'>577</span> </span><span class="WHIT">					</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>578</span> </span><span class="WHIT">						</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'callback'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>579</span> </span><span class="WHIT">						</span><span class="NAME">execute</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>580</span> </span><span class="WHIT">							</span><span class="NAME">SztakipediaTB.updateRemoteContent</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>581</span> </span><span class="WHIT">								</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">"Done."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>582</span> </span><span class="WHIT">							</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>583</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>584</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>585</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>586</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>587</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>589</span> 
<span class='line'>590</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>591</span> 	 * Initialize the toolbar. Adds a new toolbar section with tools, creates precomputable dialog windows.
<span class='line'>592</span> 	 * Shall be called only once.  
<span class='line'>593</span> 	 * @private
<span class='line'>594</span> 	 */</span><span class="WHIT">
<span class='line'>595</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.init</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>596</span> 
<span class='line'>597</span> </span><span class="WHIT">		</span><span class="COMM">//alert('init: ' + $j('div[rel=sztakipedias]')[0]);</span><span class="WHIT">
<span class='line'>598</span> </span><span class="WHIT">		</span><span class="COMM">//		if (typeof $j('div[rel=sztakipedias]')[0] != 'undefined') { // Mystery IE bug workaround</span><span class="WHIT">
<span class='line'>599</span> </span><span class="WHIT">		</span><span class="COMM">//			return;</span><span class="WHIT">
<span class='line'>600</span> </span><span class="WHIT">		</span><span class="COMM">//		}</span><span class="WHIT">
<span class='line'>601</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'head'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">trigger</span><span class="PUNC">(</span><span class="STRN">'sztakipediatoolbarbase'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// allow callbacks</span><span class="WHIT">
<span class='line'>602</span> </span><span class="COMM">//		alert('init');</span><span class="WHIT">
<span class='line'>603</span> </span><span class="WHIT">		
<span class='line'>604</span> 		</span><span class="NAME">importScriptURI</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'basedir'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'SztakipediaClient.js'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>605</span> </span><span class="WHIT">		
<span class='line'>606</span> 
<span class='line'>607</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">refsection</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>608</span> </span><span class="WHIT">			</span><span class="NAME">sections</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>609</span> </span><span class="WHIT">				</span><span class="NAME">sztakipedias</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>610</span> </span><span class="WHIT">					</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'toolbar'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>611</span> </span><span class="WHIT">					</span><span class="NAME">labelMsg</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-section-label'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>612</span> </span><span class="WHIT">					</span><span class="NAME">groups</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>613</span> </span><span class="WHIT">								</span><span class="STRN">'suggestions'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>614</span> </span><span class="WHIT">									</span><span class="STRN">'label'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Suggestions'</span><span class="WHIT"> </span><span class="COMM">// FIXME use labelMsg for a localized label</span><span class="WHIT">
<span class='line'>615</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>616</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">						
<span class='line'>617</span> 				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>618</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>619</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>620</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'modal'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>621</span> </span><span class="WHIT">			</span><span class="COMM">// $j('#sztakipedia-???').dialog('option', 'modal', false);</span><span class="WHIT">
<span class='line'>622</span> </span><span class="WHIT">			</span><span class="NAME">appendCSS</span><span class="PUNC">(</span><span class="STRN">".ui-widget-overlay {"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"display:none !important;"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>623</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addToToolbar'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">refsection</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>625</span> </span><span class="WHIT">		
<span class='line'>626</span> 		
<span class='line'>627</span> 		
<span class='line'>628</span> 		</span><span class="COMM">// FIXME</span><span class="WHIT">
<span class='line'>629</span> </span><span class="WHIT">		</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">sztakipediaTemplate</span><span class="PUNC">(</span><span class="STRN">'cite book'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'book'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="COMM">// Basic fields</span><span class="WHIT">
<span class='line'>630</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>631</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"last"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>632</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillprop"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"last1"</span><span class="WHIT">
<span class='line'>633</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>634</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"first"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>635</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillprop"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"first1"</span><span class="WHIT">
<span class='line'>636</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>637</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"title"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>638</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillprop"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"title"</span><span class="WHIT">
<span class='line'>639</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>640</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"year"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>641</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillprop"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"year"</span><span class="WHIT">
<span class='line'>642</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>643</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"publisher"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>644</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillprop"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"publisher"</span><span class="WHIT">
<span class='line'>645</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>646</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"location"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>647</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillprop"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"location"</span><span class="WHIT">
<span class='line'>648</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>649</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"isbn"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>650</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillid"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"isbn"</span><span class="WHIT">
<span class='line'>651</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>652</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"pages"</span><span class="WHIT">
<span class='line'>653</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>654</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"url"</span><span class="WHIT">
<span class='line'>655</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>656</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"author"</span><span class="WHIT">
<span class='line'>657</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="WHIT">  </span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="COMM">// Expanded fields</span><span class="WHIT">
<span class='line'>658</span> </span><span class="WHIT">		                                   			     </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>659</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"edition"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>660</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillprop"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"edition"</span><span class="WHIT">
<span class='line'>661</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>662</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"authorlink"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>663</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"tooltip"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"sztakipedia-authorlink-tooltip"</span><span class="WHIT">
<span class='line'>664</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>665</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"coauthors"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>666</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"autofillprop"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"coauthors"</span><span class="WHIT">
<span class='line'>667</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>668</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"editor"</span><span class="WHIT">
<span class='line'>669</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>670</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"accessdate"</span><span class="WHIT">
<span class='line'>671</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>672</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"archiveurl"</span><span class="WHIT">
<span class='line'>673</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>674</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"archivedate"</span><span class="WHIT">
<span class='line'>675</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>676</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"page"</span><span class="WHIT">
<span class='line'>677</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>678</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"language"</span><span class="WHIT">
<span class='line'>679</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>680</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"format"</span><span class="WHIT">
<span class='line'>681</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>682</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"chapter"</span><span class="WHIT">
<span class='line'>683</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>684</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"date"</span><span class="WHIT">
<span class='line'>685</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>686</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"month"</span><span class="WHIT">
<span class='line'>687</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT">		                                   				</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"quote"</span><span class="WHIT">
<span class='line'>689</span> </span><span class="WHIT">		                                   			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>690</span> 
<span class='line'>691</span> </span><span class="WHIT">		</span><span class="COMM">//SztakipediaTB.Templates['cite-book'] = SztakipediaTB.Templates['book']; </span><span class="WHIT">
<span class='line'>692</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bookprediction</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">sztakipediaTemplate</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-bookprediction'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'bookprediction'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="COMM">// Basic fields</span><span class="WHIT">
<span class='line'>693</span> </span><span class="WHIT">				</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>694</span> </span><span class="WHIT">					</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"title"</span><span class="WHIT">
<span class='line'>695</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>696</span> </span><span class="WHIT">					</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"author"</span><span class="WHIT">
<span class='line'>697</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="COMM">// Expanded fields</span><span class="WHIT">
<span class='line'>698</span> </span><span class="WHIT">				      	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>699</span> </span><span class="WHIT">							</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"issued"</span><span class="WHIT">
<span class='line'>700</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>701</span> </span><span class="WHIT">							</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"description"</span><span class="WHIT">							
<span class='line'>702</span> 						</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>703</span> </span><span class="WHIT">							</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"description"</span><span class="WHIT">							
<span class='line'>704</span> 						</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>705</span> </span><span class="WHIT">							</span><span class="STRN">"field"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"identifier"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>706</span> 							</span><span class="STRN">"tooltip"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-bookprediction-identifier-tooltip'</span><span class="WHIT">
<span class='line'>707</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>708</span> </span><span class="WHIT">		</span><span class="NAME">bookprediction.refs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>709</span> </span><span class="WHIT">		</span><span class="NAME">bookprediction.preview</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>710</span> </span><span class="WHIT">		
<span class='line'>711</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">temlist</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>712</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>713</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>714</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.Templates</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>715</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.Templates</span><span class="PUNC">[</span><span class="NAME">t</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>716</span> </span><span class="COMM">//			alert(t + "," + tem);</span><span class="WHIT">
<span class='line'>717</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.toDialog</span><span class="PUNC">(</span><span class="NAME">tem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>718</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogid</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'titleMsg'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>719</span> 
<span class='line'>720</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">actionobj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT">				</span><span class="STRN">'type'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'dialog'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT">				</span><span class="STRN">'module'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">dialogid</span><span class="WHIT">
<span class='line'>723</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>724</span> 
<span class='line'>725</span> </span><span class="WHIT">			</span><span class="COMM">// FIXME HACK</span><span class="WHIT">
<span class='line'>726</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">messages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>727</span> </span><span class="WHIT">			</span><span class="NAME">messages</span><span class="PUNC">[</span><span class="NAME">dialogid</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tem.templatename</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>728</span> </span><span class="WHIT">			</span><span class="NAME">mw.usability.addMessages</span><span class="PUNC">(</span><span class="NAME">messages</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>729</span> 
<span class='line'>730</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogobj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>731</span> </span><span class="WHIT">			</span><span class="NAME">dialogobj</span><span class="PUNC">[</span><span class="NAME">dialogid</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>732</span> </span><span class="WHIT">			</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addDialog'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dialogobj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>733</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'modal'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>734</span> </span><span class="WHIT">				</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'id'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'option'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'modal'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>735</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>736</span> </span><span class="WHIT">			</span><span class="NAME">temlist</span><span class="PUNC">[</span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">tem.shortform</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>737</span> </span><span class="WHIT">				</span><span class="NAME">label</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">tem.templatename</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>738</span> </span><span class="WHIT">				</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">actionobj</span><span class="WHIT">
<span class='line'>739</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>740</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>741</span> 
<span class='line'>742</span> </span><span class="WHIT">		</span><span class="COMM">// add suggestion tools</span><span class="WHIT">
<span class='line'>743</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.initLink</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'>744</span> 		</span><span class="NAME">SztakipediaTB.initCategory</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'>745</span> 		</span><span class="NAME">SztakipediaTB.initInfobox</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>746</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.initBook</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>747</span> </span><span class="WHIT">		
<span class='line'>748</span> 		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'debug'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">		
<span class='line'>749</span> 			</span><span class="NAME">SztakipediaTB.initInfo</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>750</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>751</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>752</span> 
<span class='line'>753</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>754</span> 	 * Load local data - messages, cite templates, etc.
<span class='line'>755</span> 	 */</span><span class="WHIT">
<span class='line'>756</span> </span><span class="WHIT">	</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="NAME">document</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">ready</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>757</span> 
<span class='line'>758</span> </span><span class="WHIT">		</span><span class="COMM">// TODO support more languages</span><span class="WHIT">
<span class='line'>759</span> </span><span class="WHIT">		</span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wgUserLanguage</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>760</span> </span><span class="WHIT">			</span><span class="COMM">// case 'de': // German</span><span class="WHIT">
<span class='line'>761</span> </span><span class="WHIT">			</span><span class="COMM">// var RefToolbarMessages =</span><span class="WHIT">
<span class='line'>762</span> </span><span class="WHIT">			</span><span class="COMM">// importScript('MediaWiki:RefToolbarMessages-de.js');</span><span class="WHIT">
<span class='line'>763</span> </span><span class="WHIT">			</span><span class="COMM">// break;</span><span class="WHIT">
<span class='line'>764</span> </span><span class="WHIT">			</span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT"> 
<span class='line'>765</span> 				</span><span class="COMM">// English</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT">				</span><span class="COMM">// var RefToolbarMessages =</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT">				</span><span class="COMM">// importScript('MediaWiki:RefToolbarMessages-en.js');</span><span class="WHIT">
<span class='line'>768</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">SztakipediaToolbarMessages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">importScriptURI</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'basedir'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'SztakipediaToolbarMessages-en.js'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>771</span> 
<span class='line'>772</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>773</span>    * Return a localized string for the key if present, or the key itself surrounded by braces if a localized string is missing.
<span class='line'>774</span>    * @param {string} msgid The message key, e.g. 'sztakipedia-accept'.
<span class='line'>775</span>    * @return {string} The localized string, or the encapsulated key.
<span class='line'>776</span>    */</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">msgid</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="NAME">msgid</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>779</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>780</span> </span><span class="WHIT">			</span><span class="NAME">msg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'{'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">msgid</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'}'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>781</span> </span><span class="WHIT">		
<span class='line'>782</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>783</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>784</span> 
<span class='line'>785</span> </span><span class="WHIT">	</span><span class="COMM">// REF FUNCTIONS</span><span class="WHIT">
<span class='line'>786</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>787</span> 	 * Actually assemble a ref from user input
<span class='line'>788</span> 	 * @param {boolean} inneronly Omit &lt;ref&gt; tags.
<span class='line'>789</span> 	 * @param {boolean} forinsert
<span class='line'>790</span> 	 * @private
<span class='line'>791</span> 	 */</span><span class="WHIT">
<span class='line'>792</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.getRef</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">inneronly</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">forinsert</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>793</span> </span><span class="WHIT">		
<span class='line'>794</span> 		</span><span class="COMM">// TODO on forinsert == true, cross-call CiteTB</span><span class="WHIT">
<span class='line'>795</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>796</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">templatename</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template.templatename</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>797</span> </span><span class="WHIT">		
<span class='line'>798</span> 		</span><span class="COMM">// disable &lt;ref> for non-citation templates</span><span class="WHIT">
<span class='line'>799</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">template.refs</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>800</span> </span><span class="WHIT">			</span><span class="NAME">inneronly</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>801</span> </span><span class="WHIT">		
<span class='line'>802</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>803</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">refobj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>804</span> </span><span class="WHIT">			</span><span class="STRN">'shorttag'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT">
<span class='line'>805</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>806</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">inneronly</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>807</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-group'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>808</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">refname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-name'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>809</span> </span><span class="WHIT">			</span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;ref'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>810</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">refname</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>811</span> </span><span class="WHIT">				</span><span class="NAME">refname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j.trim</span><span class="PUNC">(</span><span class="NAME">refname</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT">				</span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">' name="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getQuotedString</span><span class="PUNC">(</span><span class="NAME">refname</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>813</span> </span><span class="WHIT">				</span><span class="NAME">refobj.refname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">refname</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>814</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">group</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>816</span> </span><span class="WHIT">				</span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j.trim</span><span class="PUNC">(</span><span class="NAME">group</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>817</span> </span><span class="WHIT">				</span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">' group="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getQuotedString</span><span class="PUNC">(</span><span class="NAME">group</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>818</span> </span><span class="WHIT">				</span><span class="NAME">refobj.refgroup</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">group</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT">			</span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>822</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'{{'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">templatename</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>823</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">template.basic.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>824</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template.basic</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">field</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>825</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>826</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">field</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>827</span> </span><span class="WHIT">				</span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'|'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'='</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>828</span> </span><span class="WHIT">				</span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j.trim</span><span class="PUNC">(</span><span class="NAME">field.replace</span><span class="PUNC">(</span><span class="STRN">"|"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"{{!}}"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>829</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>830</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>831</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-form-status'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'closed'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>832</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">template.extra.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>833</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template.extra</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">field</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>834</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>835</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">field</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>836</span> </span><span class="WHIT">					</span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'|'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'='</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>837</span> </span><span class="WHIT">					</span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j.trim</span><span class="PUNC">(</span><span class="NAME">field.replace</span><span class="PUNC">(</span><span class="STRN">"|"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"{{!}}"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>838</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>839</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>840</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>841</span> </span><span class="WHIT">		</span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'}}'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>842</span> </span><span class="WHIT">		</span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>843</span> </span><span class="WHIT">		</span><span class="NAME">refobj.content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>844</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">inneronly</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>845</span> </span><span class="WHIT">			</span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;/ref>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>846</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>847</span> </span><span class="WHIT">		</span><span class="COMM">//alert('getRef: ' + res);</span><span class="WHIT">
<span class='line'>848</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>849</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>850</span> 
<span class='line'>851</span> 
<span class='line'>852</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>853</span> 	 * Retrieve book suggestions. Also adds a book search form to the dialog window.
<span class='line'>854</span> 	 * @private
<span class='line'>855</span> 	 */</span><span class="WHIT">
<span class='line'>856</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.loadBookSuggestions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>857</span> </span><span class="WHIT">		</span><span class="COMM">// add search form if not already there</span><span class="WHIT">
<span class='line'>858</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipediatoolbar-dialog-bookprediction-form:empty'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>859</span> </span><span class="WHIT">			</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-search-form'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>860</span> </span><span class="WHIT">			</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>861</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-bookprediction-form-title'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>862</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-dialog-block-title'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>863</span> </span><span class="WHIT">			</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>864</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.Templates</span><span class="PUNC">[</span><span class="STRN">'sztakipedia-bookprediction'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getForm</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>865</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">removeClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-form-container'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>866</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;input/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>867</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'type'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'checkbox'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>868</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'name'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-bookprediction-token-checkbox'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>869</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-bookprediction-token-checkbox'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>870</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-checkbox'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>871</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'checked'</span><span class="PUNC">,</span><span class="STRN">'checked'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>872</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;label/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>873</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'for'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-bookprediction-token-checkbox'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>874</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-checkbox'</span><span class="PUNC">)</span><span class="WHIT">	
<span class='line'>875</span> 							</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-bookprediction-form-token-label'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>876</span> </span><span class="WHIT">					</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>877</span> </span><span class="WHIT">			</span><span class="PUNC">.</span><span class="NAME">after</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>878</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-bookprediction-suggestions-title'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>879</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-dialog-block-title'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>880</span> 
<span class='line'>881</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.updateRemoteContent</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>882</span> </span><span class="WHIT">			</span><span class="NAME">SztakipediaClient.buildDialogs</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.setupBookSuggestions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.token</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'bookprediction'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>883</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>884</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>885</span> 
<span class='line'>886</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>887</span> 	 * Retrieve internal link suggestions.
<span class='line'>888</span> 	 * @private
<span class='line'>889</span> 	 */</span><span class="WHIT">
<span class='line'>890</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.loadLinkSuggestions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>891</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.updateRemoteContent</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>892</span> </span><span class="WHIT">			</span><span class="NAME">SztakipediaClient.buildDialogs</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.setupLinkSuggestions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.token</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'pagelinks'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>893</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>894</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>895</span> </span><span class="WHIT">	
<span class='line'>896</span> 	</span><span class="COMM">/**
<span class='line'>897</span> 	 * Retrieve category suggestions.
<span class='line'>898</span> 	 * @private
<span class='line'>899</span> 	 */</span><span class="WHIT">
<span class='line'>900</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.loadCategorySuggestions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>901</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.updateRemoteContent</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>902</span> </span><span class="WHIT">			</span><span class="NAME">SztakipediaClient.buildDialogs</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.setupCategorySuggestions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.token</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'categoryprediction'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>903</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>904</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>905</span> </span><span class="WHIT">	
<span class='line'>906</span> 	</span><span class="COMM">/**
<span class='line'>907</span> 	 * Retrieve infobox suggestions.
<span class='line'>908</span> 	 * @private
<span class='line'>909</span> 	 */</span><span class="WHIT">
<span class='line'>910</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.loadInfoboxSuggestions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>911</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.updateRemoteContent</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>912</span> </span><span class="WHIT">			</span><span class="NAME">SztakipediaClient.buildDialogs</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.setupInfoboxSuggestions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.token</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'infoboxprediction'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>913</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>914</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>915</span> </span><span class="WHIT">	
<span class='line'>916</span> 	</span><span class="COMM">/**
<span class='line'>917</span> 	 * Search for books based on the search form.
<span class='line'>918</span> 	 * @private
<span class='line'>919</span> 	 */</span><span class="WHIT">
<span class='line'>920</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.handleBookFormSubmit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>921</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>922</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>923</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>924</span> </span><span class="WHIT">		
<span class='line'>925</span> 		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">template.basic.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>926</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template.basic</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">field</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>927</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>928</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>929</span> </span><span class="WHIT">				</span><span class="NAME">params</span><span class="PUNC">[</span><span class="NAME">fieldname</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">field</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>930</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>931</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-form-status'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'closed'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>932</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">template.extra.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>933</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template.extra</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">field</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>934</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fieldname</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>935</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>936</span> </span><span class="WHIT">					</span><span class="NAME">params</span><span class="PUNC">[</span><span class="NAME">fieldname</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">field</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>937</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>938</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>939</span> </span><span class="WHIT">		
<span class='line'>940</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">includeToken</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-bookprediction-token-checkbox'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'checked'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'checked'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//  jQuery 1.4.x</span><span class="WHIT">
<span class='line'>941</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaClient.buildDialogs</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.setupBookSuggestions</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>942</span> 				</span><span class="NAME">includeToken</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.token</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>943</span> 				</span><span class="STRN">'bookprediction'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>944</span> 				</span><span class="NAME">params</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>945</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipediatoolbar-dialog-bookprediction-content'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'style'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'opacity:0.3;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>946</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>947</span> 
<span class='line'>948</span> </span><span class="WHIT">	</span><span class="COMM">// ==============</span><span class="WHIT">
<span class='line'>949</span> </span><span class="WHIT">	</span><span class="COMM">// AJAX FUNCTIONS</span><span class="WHIT">
<span class='line'>950</span> </span><span class="WHIT">	</span><span class="COMM">// ==============</span><span class="WHIT">
<span class='line'>951</span> </span><span class="WHIT">	
<span class='line'>952</span> 	</span><span class="COMM">/**
<span class='line'>953</span> 	 * Parse some wikitext and hand it off to a callback function.
<span class='line'>954</span> 	 * @param {string} text The wikitext fragment to be parsed.
<span class='line'>955</span> 	 * @param {function(string)} callback The function to be called with the resulting HTML.
<span class='line'>956</span> 	 * @requires MediaWiki-API
<span class='line'>957</span> 	 */</span><span class="WHIT">
<span class='line'>958</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>959</span> </span><span class="WHIT">		</span><span class="COMM">//alert("wikitext: " + text);</span><span class="WHIT">
<span class='line'>960</span> </span><span class="WHIT">		</span><span class="NAME">$j.post</span><span class="PUNC">(</span><span class="NAME">wgServer</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">wgScriptPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'/api.php'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>961</span> </span><span class="WHIT">			</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'parse'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>962</span> </span><span class="WHIT">			</span><span class="NAME">title</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">wgPageName</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>963</span> </span><span class="WHIT">			</span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>964</span> </span><span class="WHIT">			</span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'text'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>965</span> </span><span class="WHIT">			</span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'json'</span><span class="WHIT">
<span class='line'>966</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>967</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="STRN">'parse'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'text'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'*'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>968</span> </span><span class="WHIT">			</span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">html</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>969</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'json'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>970</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>971</span> 
<span class='line'>972</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>973</span> 	 * Use the API to expand templates on some text
<span class='line'>974</span> 	 * @param {string} text The wikitext fragment to be expanded.
<span class='line'>975</span> 	 * @param {function(string)} callback The function to be called with the resulting HTML.
<span class='line'>976</span> 	 * @requires MediaWiki-API
<span class='line'>977</span> 	 * @private
<span class='line'>978</span> 	 */</span><span class="WHIT">
<span class='line'>979</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.expandtemplates</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>980</span> </span><span class="WHIT">		</span><span class="NAME">$j.post</span><span class="PUNC">(</span><span class="NAME">wgServer</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">wgScriptPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'/api.php'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>981</span> </span><span class="WHIT">			</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'expandtemplates'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>982</span> </span><span class="WHIT">			</span><span class="NAME">title</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">wgPageName</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>983</span> </span><span class="WHIT">			</span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>984</span> </span><span class="WHIT">			</span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'json'</span><span class="WHIT">
<span class='line'>985</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>986</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">restext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="STRN">'expandtemplates'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'*'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>987</span> </span><span class="WHIT">			</span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">restext</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>988</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'json'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>989</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>990</span> 
<span class='line'>991</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>992</span> 	 * Function to get the page text
<span class='line'>993</span> 	 * @param {function(string)} callback The function to be called with the resulting HTML.
<span class='line'>994</span> 	 * @requires MediaWiki-API
<span class='line'>995</span> 	 */</span><span class="WHIT">
<span class='line'>996</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.getPageText</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>997</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">section</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">"input[name='wpSection']"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>998</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">section</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>999</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">postdata</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1000</span> </span><span class="WHIT">				</span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'query'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1001</span> </span><span class="WHIT">				</span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'revisions'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1002</span> </span><span class="WHIT">				</span><span class="NAME">rvprop</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'content'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1003</span> </span><span class="WHIT">				</span><span class="NAME">pageids</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">wgArticleId</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="WHIT">				</span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'json'</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1006</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'expandtemplates'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1007</span> </span><span class="WHIT">				</span><span class="NAME">postdata</span><span class="PUNC">[</span><span class="STRN">'rvexpandtemplates'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'1'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1008</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1009</span> </span><span class="WHIT">			</span><span class="NAME">$j.get</span><span class="PUNC">(</span><span class="NAME">wgServer</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">wgScriptPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'/api.php'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">postdata</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1010</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pagetext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="STRN">'query'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'pages'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">wgArticleId.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'revisions'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'*'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1011</span> </span><span class="WHIT">				</span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">pagetext</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1012</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'json'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1013</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1014</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1015</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'expandtemplates'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1016</span> </span><span class="WHIT">				</span><span class="NAME">SztakipediaTB.expandtemplates</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#wpTextbox1'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'getContents'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1017</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1018</span> </span><span class="WHIT">			</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1019</span> </span><span class="WHIT">				</span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#wpTextbox1'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'getContents'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1020</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1021</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1022</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1023</span> 
<span class='line'>1024</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1025</span> 	 *  Autofill a template from an ID (ISBN, DOI, PMID)
<span class='line'>1026</span> 	 */</span><span class="WHIT">
<span class='line'>1027</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.initAutofill</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1028</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">elemid</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1029</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/^sztakipedia\-auto\-(.*?)\-(.*)\-(.*)$/</span><span class="PUNC">.</span><span class="NAME">exec</span><span class="PUNC">(</span><span class="NAME">elemid</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1030</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1031</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1032</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">autotype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1033</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">tem</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">field</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1034</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1035</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1036</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1037</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'http://toolserver.org/~alexz/ref/lookup.php?'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1038</span> </span><span class="WHIT">		</span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">autotype</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'='</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1039</span> </span><span class="WHIT">		</span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&template='</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">tem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1040</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">'script'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1041</span> </span><span class="WHIT">		</span><span class="NAME">s.setAttribute</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1042</span> </span><span class="WHIT">		</span><span class="NAME">s.setAttribute</span><span class="PUNC">(</span><span class="STRN">'type'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'text/javascript'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1043</span> </span><span class="WHIT">		</span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">'head'</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">appendChild</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1044</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1045</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1046</span> 
<span class='line'>1047</span> </span><span class="WHIT">	</span><span class="COMM">// FORM DIALOG FUNCTIONS</span><span class="WHIT">
<span class='line'>1048</span> </span><span class="WHIT">	</span><span class="COMM">// fill the accessdate param with the current date</span><span class="WHIT">
<span class='line'>1049</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.fillAccessdate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1050</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">elemid</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1051</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/^sztakipedia\-date\-(.*?)\-(.*)$/</span><span class="PUNC">.</span><span class="NAME">exec</span><span class="PUNC">(</span><span class="NAME">elemid</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1052</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1053</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1054</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">DT</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1055</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">datestr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.formatDate</span><span class="PUNC">(</span><span class="NAME">DT</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1056</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">field</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="NAME">datestr</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1057</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1058</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1059</span> 
<span class='line'>1060</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.formatDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">DT</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1061</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">datestr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'date format'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1062</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">zmonth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1063</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">DT.getUTCMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1064</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1065</span> </span><span class="WHIT">			</span><span class="NAME">zmonth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">month.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1066</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1067</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1068</span> </span><span class="WHIT">			</span><span class="NAME">zmonth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">month.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1069</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1070</span> </span><span class="WHIT">		</span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">month.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1071</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">zdate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1072</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">DT.getUTCDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1073</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1074</span> </span><span class="WHIT">			</span><span class="NAME">zdate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">date.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1075</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1076</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1077</span> </span><span class="WHIT">			</span><span class="NAME">zdate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">date.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1078</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1079</span> </span><span class="WHIT">		</span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">date.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1080</span> </span><span class="WHIT">		</span><span class="NAME">datestr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">datestr.replace</span><span class="PUNC">(</span><span class="STRN">'&lt;date>'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">date</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1081</span> </span><span class="WHIT">		</span><span class="NAME">datestr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">datestr.replace</span><span class="PUNC">(</span><span class="STRN">'&lt;month>'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">month</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1082</span> </span><span class="WHIT">		</span><span class="NAME">datestr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">datestr.replace</span><span class="PUNC">(</span><span class="STRN">'&lt;zdate>'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">zdate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1083</span> </span><span class="WHIT">		</span><span class="NAME">datestr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">datestr.replace</span><span class="PUNC">(</span><span class="STRN">'&lt;zmonth>'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">zmonth</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1084</span> </span><span class="WHIT">		</span><span class="NAME">datestr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">datestr.replace</span><span class="PUNC">(</span><span class="STRN">'&lt;monthname>'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'months'</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NAME">DT.getUTCMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1085</span> </span><span class="WHIT">		</span><span class="NAME">datestr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">datestr.replace</span><span class="PUNC">(</span><span class="STRN">'&lt;year>'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DT.getUTCFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1086</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">datestr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1087</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1088</span> 
<span class='line'>1089</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1090</span> 	 * Callback function for parsed preview
<span class='line'>1091</span> 	 * @param {string} parsed The HTML string.
<span class='line'>1092</span> 	 */</span><span class="WHIT">
<span class='line'>1093</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.fillNrefPreview</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">parsed</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1094</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-parsed-label'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">show</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1095</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-namedref-parsed'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">parsed</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1096</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1097</span> 
<span class='line'>1098</span> </span><span class="WHIT">	
<span class='line'>1099</span> 	</span><span class="COMM">/**
<span class='line'>1100</span> 	 * Callback function for parsed preview.
<span class='line'>1101</span> 	 * @param {string} text The HTML fragment.
<span class='line'>1102</span> 	 * 
<span class='line'>1103</span> 	 */</span><span class="WHIT">
<span class='line'>1104</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.fillTemplatePreview</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1105</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1106</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">div</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">"#sztakipediatoolbar-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1107</span> </span><span class="WHIT">		</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-prev-parsed-label'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">show</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1108</span> </span><span class="WHIT">		</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-preview-parsed'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1109</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">container</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-form-container'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1110</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">scrollTo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">container.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-preview-parsed'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1111</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.scrollTo</span><span class="PUNC">(</span><span class="NAME">scrollTo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">container</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'fast'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'>1112</span> 	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1113</span> 
<span class='line'>1114</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1115</span> 	 *  Click handler for template parsed preview
<span class='line'>1116</span> 	 */</span><span class="WHIT">
<span class='line'>1117</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.prevParseClick</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1118</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1119</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ref</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getRef</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1120</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">div</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">"#sztakipediatoolbar-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1121</span> </span><span class="WHIT">		</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-prev-parse'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1122</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.parse</span><span class="PUNC">(</span><span class="NAME">ref</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.fillTemplatePreview</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1123</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1124</span> 
<span class='line'>1125</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1126</span> 	 * Show/hide the extra fields in the dialog box
<span class='line'>1127</span> 	 */</span><span class="WHIT">
<span class='line'>1128</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.showHideExtra</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1129</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1130</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">div</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">"#sztakipediatoolbar-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1131</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">div.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1132</span> </span><span class="WHIT">			</span><span class="NAME">div</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">"#sztakipediatoolbar-dialog-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-form"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1133</span> </span><span class="WHIT">			
<span class='line'>1134</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">setting</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-form-status"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1135</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">setting</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'closed'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1136</span> </span><span class="WHIT">			</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-form-status"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="STRN">'open'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1137</span> </span><span class="WHIT">			</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-extra-fields'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">show</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1138</span> </span><span class="WHIT">				</span><span class="COMM">// jQuery adds "display:block", which screws things up</span><span class="WHIT">
<span class='line'>1139</span> </span><span class="WHIT">					</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-extra-fields'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'style'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'width:100%; background-color:transparent;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1140</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1141</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1142</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1143</span> </span><span class="WHIT">			</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-form-status"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="STRN">'closed'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1144</span> </span><span class="WHIT">			</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-extra-fields'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1145</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1146</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1147</span> </span><span class="WHIT">	
<span class='line'>1148</span> 	</span><span class="COMM">/**
<span class='line'>1149</span> 	 * Select given character range in the text field.
<span class='line'>1150</span> 	 * @param {number} start The first character position (inclusive).
<span class='line'>1151</span> 	 * @param {number} end The last character position (exclusive).
<span class='line'>1152</span> 	 * @param {Object} [field] The textarea to select text in.
<span class='line'>1153</span> 	 */</span><span class="WHIT">
<span class='line'>1154</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.selectRange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">start</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">end</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">field</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1155</span> </span><span class="WHIT">		</span><span class="COMM">//alert('Select [' + start +'-' + end + ']');</span><span class="WHIT">
<span class='line'>1156</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1157</span> </span><span class="WHIT">			</span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">get</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'>1158</span> 		
<span class='line'>1159</span> 		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1160</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">'Invalid range ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1161</span> </span><span class="WHIT">		
<span class='line'>1162</span> 		 </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">field.setSelectionRange</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// Modern browsers </span><span class="WHIT">
<span class='line'>1163</span> </span><span class="WHIT">		    </span><span class="NAME">field.focus</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1164</span> </span><span class="WHIT">	        </span><span class="NAME">field.setSelectionRange</span><span class="PUNC">(</span><span class="NAME">start</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">end</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1165</span> </span><span class="WHIT">		 </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>1166</span> 		 </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">field.createTextRange</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// IE (&lt;9)</span><span class="WHIT">
<span class='line'>1167</span> 
<span class='line'>1168</span> </span><span class="WHIT">	        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">newend</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">start</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1169</span> </span><span class="WHIT">	        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">selRange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">field.createTextRange</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1170</span> </span><span class="WHIT">	        </span><span class="NAME">selRange.collapse</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1171</span> </span><span class="WHIT">	        </span><span class="NAME">selRange.moveStart</span><span class="PUNC">(</span><span class="STRN">"character"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">start</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1172</span> </span><span class="WHIT">	        </span><span class="NAME">selRange.moveEnd</span><span class="PUNC">(</span><span class="STRN">"character"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newend</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1173</span> </span><span class="WHIT">	        </span><span class="NAME">selRange.select</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1174</span> </span><span class="WHIT">		    </span><span class="NAME">field.focus</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1175</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1176</span> </span><span class="WHIT">	    	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Unrecognized browser!"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1177</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1178</span> 
<span class='line'>1179</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1180</span> 
<span class='line'>1181</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1182</span> 	 * Resets form fields and previews.
<span class='line'>1183</span> 	 * @private
<span class='line'>1184</span> 	 */</span><span class="WHIT">
<span class='line'>1185</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.resetForm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1186</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1187</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1188</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">div</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">"#sztakipediatoolbar-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1189</span> </span><span class="WHIT">		</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-preview-label'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1190</span> </span><span class="WHIT">		</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-ref-preview'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1191</span> </span><span class="WHIT">		</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-prev-parsed-label'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1192</span> </span><span class="WHIT">		</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-preview-parsed'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1193</span> </span><span class="WHIT">		</span><span class="NAME">div.find</span><span class="PUNC">(</span><span class="STRN">'.sztakipedia-prev-parse'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1194</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' input[type=text]'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1195</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1196</span> 
<span class='line'>1197</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1198</span> 	 * Produce HTML for the link suggestions dialog.
<span class='line'>1199</span> 	 * @param {Object} dialogs
<span class='line'>1200</span> 	 */</span><span class="WHIT">
<span class='line'>1201</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.setupLinkSuggestions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1202</span> </span><span class="WHIT">		
<span class='line'>1203</span> 		</span><span class="COMM">// FIXME some hacks to provide as-of-yet missing suggestion attributes</span><span class="WHIT">
<span class='line'>1204</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1205</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dialogId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1206</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1207</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">suggestionId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1208</span> </span><span class="WHIT">				
<span class='line'>1209</span> 				</span><span class="COMM">// FIXME hack to populate missing URL, remove after API provides URLs</span><span class="WHIT">
<span class='line'>1210</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="STRN">'url'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1211</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">capitaliseFirstLetter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1212</span> </span><span class="WHIT">					    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">string.charAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">string.slice</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1213</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1214</span> 
<span class='line'>1215</span> </span><span class="WHIT">					</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'url'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'http://en.wikipedia.org/wiki/'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">capitaliseFirstLetter</span><span class="PUNC">(</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'essence'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1216</span> </span><span class="WHIT">					</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'meta'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">capitaliseFirstLetter</span><span class="PUNC">(</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'essence'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1217</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1218</span> </span><span class="WHIT">				
<span class='line'>1219</span> 				</span><span class="COMM">// FIXME hack to populate missing thumbnail, remove after API provides thumbnails</span><span class="WHIT">
<span class='line'>1220</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="STRN">'thumbnail'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1221</span> </span><span class="WHIT">					</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'thumbnail'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1222</span> </span><span class="WHIT">							</span><span class="STRN">'url'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/No-Book.svg/80px-No-Book.svg.png'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1223</span> </span><span class="WHIT">							</span><span class="STRN">'width'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">80</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1224</span> </span><span class="WHIT">							</span><span class="STRN">'height'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">96</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1225</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1226</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1227</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1228</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.setupDialogs</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'link'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-link-content'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1229</span> </span><span class="WHIT">		
<span class='line'>1230</span> 	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1231</span> </span><span class="WHIT">	
<span class='line'>1232</span> 	</span><span class="COMM">/**
<span class='line'>1233</span> 	 * Produce HTML for the category suggestions dialog.
<span class='line'>1234</span> 	 * @param {Object} dialogs
<span class='line'>1235</span> 	 */</span><span class="WHIT">
<span class='line'>1236</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.setupCategorySuggestions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1237</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.setupDialogs</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'category'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-category'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1238</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1239</span> </span><span class="WHIT">	
<span class='line'>1240</span> 	</span><span class="COMM">/**
<span class='line'>1241</span> 	 * Produce HTML for the infobox suggestions dialog.
<span class='line'>1242</span> 	 * @param {Object} dialogs
<span class='line'>1243</span> 	 */</span><span class="WHIT">
<span class='line'>1244</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.setupInfoboxSuggestions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1245</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1246</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dialogId</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1247</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dialogId</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">suggestionId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1248</span> </span><span class="WHIT">				
<span class='line'>1249</span> 				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'html'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1250</span> </span><span class="WHIT">					</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'template'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.parseTemplateFromXhtml</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="NAME">SztakipediaClient.parseXML</span><span class="PUNC">(</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'html'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/&lt;br\/>$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// TODO hack to remove trailing &lt;br> element</span><span class="WHIT">
<span class='line'>1251</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1252</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1253</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1254</span> </span><span class="WHIT">		
<span class='line'>1255</span> 		</span><span class="NAME">SztakipediaTB.setupDialogs</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'infobox'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-infobox-content'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1256</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1257</span> </span><span class="WHIT">	
<span class='line'>1258</span> 	</span><span class="COMM">/**
<span class='line'>1259</span> 	 * Produce HTML for the book suggestions dialog.
<span class='line'>1260</span> 	 * @param {Object} dialogs
<span class='line'>1261</span> 	 */</span><span class="WHIT">		
<span class='line'>1262</span> 	</span><span class="NAME">SztakipediaTB.setupBookSuggestions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1263</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipediatoolbar-dialog-bookprediction-content'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'style'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'opacity:1;'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'>1264</span> 		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1265</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dialogId</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1266</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dialogId</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">suggestionId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1267</span> </span><span class="WHIT">				
<span class='line'>1268</span> 				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'html'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1269</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.parseTemplateFromXhtml</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="NAME">SztakipediaClient.parseXML</span><span class="PUNC">(</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'html'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/&lt;br\/>$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// TODO hack to remove trailing &lt;br> element</span><span class="WHIT">
<span class='line'>1270</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">chunks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1271</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'author'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">template</span><span class="PUNC">[</span><span class="STRN">'params'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1272</span> </span><span class="WHIT">						</span><span class="NAME">chunks.push</span><span class="PUNC">(</span><span class="NAME">template</span><span class="PUNC">[</span><span class="STRN">'params'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'author'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1273</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'year'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">template</span><span class="PUNC">[</span><span class="STRN">'params'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1274</span> </span><span class="WHIT">						</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'meta'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template</span><span class="PUNC">[</span><span class="STRN">'params'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'year'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1275</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'isbn'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">template</span><span class="PUNC">[</span><span class="STRN">'params'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1276</span> </span><span class="WHIT">						</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'meta'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template</span><span class="PUNC">[</span><span class="STRN">'params'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'isbn'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1277</span> </span><span class="WHIT">					</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'meta'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">chunks.join</span><span class="PUNC">(</span><span class="STRN">', '</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1278</span> </span><span class="WHIT">					
<span class='line'>1279</span> 					</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'template'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1280</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1281</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1282</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1283</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.setupDialogs</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'bookprediction'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipediatoolbar-dialog-bookprediction-content'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1284</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1285</span> </span><span class="WHIT">	
<span class='line'>1286</span> 	</span><span class="COMM">/**
<span class='line'>1287</span> 	 * Create HTML corresponding to a set of generic dialogs.
<span class='line'>1288</span> 	 * 
<span class='line'>1289</span> 	 * @param {Object} dialogs The list of dialogs.
<span class='line'>1290</span> 	 * @param {string} sname The template's short name.
<span class='line'>1291</span> 	 * @param {string} elementId The DOM element's id attribute to place the HTML in, and to register event listeners for.
<span class='line'>1292</span> 	 */</span><span class="WHIT"> 
<span class='line'>1293</span> 	</span><span class="NAME">SztakipediaTB.setupDialogs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">elementId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1294</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">stuff</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div />'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1295</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">elementId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1296</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1297</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">'Illegal number of matched elements ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">elem.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">') for "#'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">elementId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1298</span> </span><span class="WHIT">		</span><span class="NAME">elem.html</span><span class="PUNC">(</span><span class="NAME">stuff</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1299</span> </span><span class="WHIT">		
<span class='line'>1300</span> 		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dialogs.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1301</span> </span><span class="WHIT">			</span><span class="COMM">// TODO also check number of suggestions, there may be 0</span><span class="WHIT">
<span class='line'>1302</span> </span><span class="WHIT">			</span><span class="NAME">stuff.text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-no-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestions'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1303</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1304</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1305</span> </span><span class="WHIT">			</span><span class="NAME">stuff.text</span><span class="PUNC">(</span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-suggestions-intro'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1306</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1307</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dialogId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1308</span> </span><span class="WHIT">				
<span class='line'>1309</span> 				</span><span class="COMM">// API dialog block</span><span class="WHIT">
<span class='line'>1310</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">block</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1311</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1312</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-dialog-block'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1313</span> </span><span class="WHIT">			
<span class='line'>1314</span> 				</span><span class="COMM">// Dialog intro, indirectly specified by key</span><span class="WHIT">
<span class='line'>1315</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'introkey'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1316</span> </span><span class="WHIT">					</span><span class="NAME">block.append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1317</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-dialog-block-title'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1318</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'introkey'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1319</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'text'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getOption</span><span class="PUNC">(</span><span class="STRN">'debug'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1320</span> </span><span class="WHIT">					</span><span class="NAME">block.append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1321</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-dialog-block-title'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'debug'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1322</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'text'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1323</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1324</span> </span><span class="WHIT">				
<span class='line'>1325</span> 				
<span class='line'>1326</span> 				</span><span class="COMM">// build a list representing the dialog's suggestions</span><span class="WHIT">
<span class='line'>1327</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;ul/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1328</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-list'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1329</span> </span><span class="WHIT">					</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestions-list'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1330</span> </span><span class="WHIT">				
<span class='line'>1331</span> 				</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1332</span> </span><span class="WHIT">					</span><span class="COMM">//alert(suggestionId);</span><span class="WHIT">
<span class='line'>1333</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">suggestionId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1334</span> 
<span class='line'>1335</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;li/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1336</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestion-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1337</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-container'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1338</span> </span><span class="WHIT">					
<span class='line'>1339</span> 					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">container</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1340</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-text-container'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1341</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1342</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-text'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1343</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'text'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1344</span> 
<span class='line'>1345</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'meta'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1346</span> </span><span class="WHIT">						</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1347</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-meta'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1348</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'meta'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1349</span> </span><span class="WHIT">						</span><span class="NAME">container.append</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1350</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1351</span> </span><span class="WHIT">					
<span class='line'>1352</span> 					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'contextsensitive'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'insertionstrategies'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1353</span> </span><span class="WHIT">					</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1354</span> </span><span class="WHIT">						</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'insertionstrategies'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'contextsensitive'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1355</span> </span><span class="WHIT">						</span><span class="COMM">// due to CSS padding and background, &lt;b/> is also "visible" when empty</span><span class="WHIT">
<span class='line'>1356</span> </span><span class="WHIT">						</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">snippet</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1357</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-snippet'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1358</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="STRN">'... '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'before'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1359</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;b/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'replace'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1360</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'after'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' ...'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1361</span> </span><span class="WHIT">						</span><span class="NAME">container.append</span><span class="PUNC">(</span><span class="NAME">snippet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1362</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1363</span> </span><span class="WHIT">					
<span class='line'>1364</span> 					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'thumbnail'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1365</span> </span><span class="WHIT">						</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">image</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-image-container'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1366</span> </span><span class="WHIT">						</span><span class="NAME">image.append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;img/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1367</span> </span><span class="WHIT">								</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestion-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-thumbnail'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1368</span> </span><span class="WHIT">								</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'thumbnail'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'url'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1369</span> </span><span class="COMM">//								.attr('width', suggestion['thumbnail']['width'])</span><span class="WHIT">
<span class='line'>1370</span> </span><span class="COMM">//								.attr('height', suggestion['thumbnail']['height'])</span><span class="WHIT">
<span class='line'>1371</span> </span><span class="WHIT">								</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-thumbnail'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1372</span> </span><span class="WHIT">						</span><span class="COMM">// TODO also insert source domain attribution below image (like Google search) for legal reasons</span><span class="WHIT">
<span class='line'>1373</span> </span><span class="WHIT">						</span><span class="NAME">item.append</span><span class="PUNC">(</span><span class="NAME">image</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1374</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1375</span> </span><span class="WHIT">					
<span class='line'>1376</span> 
<span class='line'>1377</span> 					</span><span class="COMM">// TODO move accept/reject/preview action icons to CSS backgrounds </span><span class="WHIT">
<span class='line'>1378</span> </span><span class="WHIT">					</span><span class="COMM">// Accept tool</span><span class="WHIT">
<span class='line'>1379</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">actions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-actions'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1380</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">acceptlink</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;a href="#" />'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1381</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-action'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1382</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestion-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-accept'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1383</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'title'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-accept'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1384</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;img/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1385</span> </span><span class="WHIT">									</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/High-contrast-dialog-ok.svg/16px-High-contrast-dialog-ok.svg.png'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1386</span> </span><span class="WHIT">									</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'alt'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-accept'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1387</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1388</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-action-title'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1389</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-accept'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1390</span> </span><span class="WHIT">					</span><span class="NAME">actions.append</span><span class="PUNC">(</span><span class="NAME">acceptlink</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1391</span> 
<span class='line'>1392</span> </span><span class="WHIT">					</span><span class="COMM">// Reject tool</span><span class="WHIT">
<span class='line'>1393</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rejectlink</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;a href="#" />'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-action'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1394</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestion-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-reject'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1395</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'title'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-reject'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1396</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;img/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1397</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/High-contrast-dialog-close.svg/16px-High-contrast-dialog-close.svg.png'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1398</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'alt'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-reject'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1399</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1400</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-action-title'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1401</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-reject'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1402</span> </span><span class="WHIT">					</span><span class="NAME">actions.append</span><span class="PUNC">(</span><span class="NAME">rejectlink</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1403</span> </span><span class="WHIT">					
<span class='line'>1404</span> 					</span><span class="COMM">// Preview tool (optional)</span><span class="WHIT">
<span class='line'>1405</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'url'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1406</span> </span><span class="WHIT">						
<span class='line'>1407</span> 						</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">previewlink</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;a/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1408</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-action'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1409</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestion-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-preview'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1410</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'title'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-preview'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1411</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'href'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="PUNC">[</span><span class="STRN">'url'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'target'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'_blank'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1412</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;img/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1413</span> </span><span class="WHIT">								</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'http://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/High-contrast-system-search.svg/16px-High-contrast-system-search.svg.png'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1414</span> </span><span class="WHIT">								</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'alt'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-preview'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1415</span> </span><span class="WHIT">							</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1416</span> </span><span class="WHIT">								</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-suggestion-action-title'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1417</span> </span><span class="WHIT">								</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-preview'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1418</span> </span><span class="WHIT">						</span><span class="NAME">actions.append</span><span class="PUNC">(</span><span class="NAME">previewlink</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">						
<span class='line'>1419</span> 					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1420</span> </span><span class="WHIT">					
<span class='line'>1421</span> 					</span><span class="NAME">container.append</span><span class="PUNC">(</span><span class="NAME">actions</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1422</span> </span><span class="WHIT">					
<span class='line'>1423</span> 					</span><span class="NAME">item.append</span><span class="PUNC">(</span><span class="NAME">container</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1424</span> </span><span class="WHIT">					
<span class='line'>1425</span> 					</span><span class="NAME">list.append</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1426</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1427</span> </span><span class="WHIT">				
<span class='line'>1428</span> 				</span><span class="NAME">stuff.after</span><span class="PUNC">(</span><span class="NAME">block.append</span><span class="PUNC">(</span><span class="NAME">list</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1429</span> </span><span class="WHIT">				
<span class='line'>1430</span> 				</span><span class="COMM">// TODO insert links to 3rd party services involved for legal reasons</span><span class="WHIT">
<span class='line'>1431</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1432</span> 
<span class='line'>1433</span> </span><span class="WHIT">			</span><span class="COMM">// attach accept/reject event listeners</span><span class="WHIT">
<span class='line'>1434</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1435</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dialogId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1436</span> </span><span class="WHIT">				</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1437</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suggestion</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">suggestionId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1438</span> </span><span class="WHIT">					
<span class='line'>1439</span> 					</span><span class="COMM">// Accept tool</span><span class="WHIT">
<span class='line'>1440</span> </span><span class="WHIT">					</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestion-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-accept'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1441</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="STRN">'click'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1442</span> </span><span class="WHIT">							</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1443</span> </span><span class="WHIT">								</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dId</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'suggestions'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">sId</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1444</span> </span><span class="COMM">//								alert('Accept "' + sId + '" ' + (typeof s));</span><span class="WHIT">
<span class='line'>1445</span> </span><span class="WHIT">							
<span class='line'>1446</span> 								</span><span class="COMM">// Close modal dialog</span><span class="WHIT">
<span class='line'>1447</span> </span><span class="WHIT">								</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipediatoolbar-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">dialog</span><span class="PUNC">(</span><span class="STRN">'close'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1448</span> </span><span class="WHIT">								
<span class='line'>1449</span> 								</span><span class="COMM">// Call API</span><span class="WHIT">
<span class='line'>1450</span> </span><span class="WHIT">								</span><span class="NAME">SztakipediaClient.answerDialog</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1451</span> </span><span class="WHIT">									</span><span class="COMM">//alert('Answer processed.');</span><span class="WHIT">
<span class='line'>1452</span> </span><span class="WHIT">								</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.token</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NAME">dId</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'builder'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1453</span> </span><span class="WHIT">								
<span class='line'>1454</span> 								</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'template'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1455</span> </span><span class="WHIT">									
<span class='line'>1456</span> 									</span><span class="COMM">// FIXME wiki-normalize</span><span class="WHIT">
<span class='line'>1457</span> </span><span class="WHIT">									</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">templateTitle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="STRN">'template'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'title'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1458</span> </span><span class="WHIT">									</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1459</span> </span><span class="WHIT">									</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">templateTitle</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.Templates</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1460</span> </span><span class="WHIT">										</span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.Templates</span><span class="PUNC">[</span><span class="NAME">templateTitle</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1461</span> </span><span class="WHIT">									</span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>1462</span> 									</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1463</span> </span><span class="WHIT">										</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'html'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1464</span> </span><span class="WHIT">											</span><span class="COMM">// create SztakipediaTemplate object</span><span class="WHIT">
<span class='line'>1465</span> </span><span class="WHIT">											</span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.addTemplateFromXhtml</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="NAME">SztakipediaClient.parseXML</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">[</span><span class="STRN">'html'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/&lt;br\/>$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// TODO hack to remove trailing &lt;br> element</span><span class="WHIT">
<span class='line'>1466</span> </span><span class="WHIT">											</span><span class="NAME">template.refs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1467</span> </span><span class="WHIT">											</span><span class="COMM">// create corresponding Wikieditor dialog</span><span class="WHIT">
<span class='line'>1468</span> </span><span class="WHIT">											</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.toDialog</span><span class="PUNC">(</span><span class="NAME">template</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1469</span> </span><span class="WHIT">											</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogobj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1470</span> </span><span class="WHIT">											</span><span class="NAME">dialogobj</span><span class="PUNC">[</span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'titleMsg'</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1471</span> </span><span class="WHIT">											</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'addDialog'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dialogobj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1472</span> </span><span class="WHIT">											
<span class='line'>1473</span> 											</span><span class="COMM">// Provide tittle message</span><span class="WHIT">
<span class='line'>1474</span> </span><span class="WHIT">											</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">messages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1475</span> </span><span class="WHIT">											</span><span class="NAME">messages</span><span class="PUNC">[</span><span class="NAME">dialog</span><span class="PUNC">[</span><span class="STRN">'titleMsg'</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template.templatename</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1476</span> </span><span class="WHIT">											</span><span class="NAME">mw.usability.addMessages</span><span class="PUNC">(</span><span class="NAME">messages</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">											
<span class='line'>1477</span> 										</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1478</span> </span><span class="WHIT">											</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Template dialog creation without HTML not implemented [template title: '"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="STRN">'template'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'title'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">"']"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1479</span> </span><span class="WHIT">										</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1480</span> </span><span class="WHIT">									</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1481</span> </span><span class="WHIT">									</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">beginEnd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.searchByInsertionStragtegy</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">[</span><span class="STRN">'insertionstrategies'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1482</span> </span><span class="WHIT">									</span><span class="NAME">SztakipediaTB.selectRange</span><span class="PUNC">(</span><span class="NAME">beginEnd</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">beginEnd</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1483</span> </span><span class="WHIT">									</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">wikiEditor</span><span class="PUNC">(</span><span class="STRN">'openDialog'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">template.shortform</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1484</span> </span><span class="WHIT">									</span><span class="NAME">SztakipediaTB.setTemplateDialogFields</span><span class="PUNC">(</span><span class="NAME">template.shortform</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="STRN">'template'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'params'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1485</span> </span><span class="WHIT">									
<span class='line'>1486</span> 								</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1487</span> </span><span class="WHIT">								</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1488</span> </span><span class="WHIT">									</span><span class="COMM">// Replace</span><span class="WHIT">
<span class='line'>1489</span> </span><span class="WHIT">									</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">beginEnd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.searchByInsertionStragtegy</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">[</span><span class="STRN">'insertionstrategies'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1490</span> </span><span class="WHIT">									</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">beginEnd</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1491</span> </span><span class="WHIT">										</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"No match!"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1492</span> </span><span class="WHIT">									</span><span class="NAME">SztakipediaTB.replaceRange</span><span class="PUNC">(</span><span class="NAME">beginEnd</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">beginEnd</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="STRN">'content'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1493</span> </span><span class="WHIT">									
<span class='line'>1494</span> 									</span><span class="COMM">// Highlight newly inserted replacement string</span><span class="WHIT">
<span class='line'>1495</span> </span><span class="WHIT">									</span><span class="NAME">SztakipediaTB.selectRange</span><span class="PUNC">(</span><span class="NAME">beginEnd</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">beginEnd</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="STRN">'content'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1496</span> </span><span class="WHIT">								</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1497</span> </span><span class="WHIT">							</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1498</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="NAME">dialogId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1499</span> </span><span class="WHIT">					
<span class='line'>1500</span> 					</span><span class="COMM">// Reject tool</span><span class="WHIT">
<span class='line'>1501</span> </span><span class="WHIT">					</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestion-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-reject'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1502</span> </span><span class="WHIT">						</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="STRN">'click'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1503</span> </span><span class="WHIT">							</span><span class="COMM">//alert('Reject "' + suggestionId + '"');</span><span class="WHIT">
<span class='line'>1504</span> </span><span class="WHIT">							</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sname</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'-dialog-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">dialogId</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-suggestion-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">suggestionId</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">fadeOut</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// .slideUp();</span><span class="WHIT">
<span class='line'>1505</span> </span><span class="WHIT">						</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1506</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1507</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1508</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1509</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1510</span> 
<span class='line'>1511</span> </span><span class="WHIT">	</span><span class="COMM">/** 
<span class='line'>1512</span> 	 * Function called to load client info
<span class='line'>1513</span> 	 * Until the contents are loaded, its just a "Loading" placeholder for each section
<span class='line'>1514</span> 	 */</span><span class="WHIT">
<span class='line'>1515</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.setupInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1516</span> 
<span class='line'>1517</span> </span><span class="WHIT">		</span><span class="COMM">// initialize blocks</span><span class="WHIT">
<span class='line'>1518</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1519</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">blocks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-info-session'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-info-dialogbuilders'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-dialog-info-processors'</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1520</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">blocks</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1521</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">blocks</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1522</span> </span><span class="WHIT">			</span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-container" class="sztakipedia-dialog-block">'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;span class="sztakipedia-dialog-block-title">'</span><span class="WHIT">
<span class='line'>1523</span> </span><span class="WHIT">					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-title'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/span>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;div id="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'">'</span><span class="WHIT">
<span class='line'>1524</span> </span><span class="WHIT">					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&nbsp;'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">mw.usability.getMsg</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-loading'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1525</span> </span><span class="WHIT">					</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;/div>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1526</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1527</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sep</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">':&nbsp;'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1528</span> </span><span class="WHIT">		</span><span class="COMM">//alert('setupInfo: ' + html);</span><span class="WHIT">
<span class='line'>1529</span> </span><span class="WHIT">		</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipediatoolbar-dialog-info'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">html</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1530</span> 
<span class='line'>1531</span> </span><span class="WHIT">		</span><span class="COMM">// sync load session info</span><span class="WHIT">
<span class='line'>1532</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1533</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">stuff</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div />'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1534</span> </span><span class="WHIT">			</span><span class="NAME">stuff.text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-info-session-intro'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1535</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;ul/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-info-session-list'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1536</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1537</span> </span><span class="WHIT">			</span><span class="COMM">// session id</span><span class="WHIT">
<span class='line'>1538</span> </span><span class="WHIT">			</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;li/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1539</span> </span><span class="WHIT">				</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-info-id'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="STRN">'Session ID'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// FIXME add to messages.js</span><span class="WHIT">
<span class='line'>1540</span> </span><span class="WHIT">				</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">sep</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1541</span> </span><span class="WHIT">				</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">SztakipediaClient.sessionid</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1542</span> </span><span class="WHIT">			</span><span class="NAME">list.append</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1543</span> 
<span class='line'>1544</span> </span><span class="WHIT">			</span><span class="COMM">// token</span><span class="WHIT">
<span class='line'>1545</span> </span><span class="WHIT">			</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;li/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1546</span> </span><span class="WHIT">				</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-info-id'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="STRN">'Token'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// FIXME add to messages.js</span><span class="WHIT">
<span class='line'>1547</span> </span><span class="WHIT">				</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">sep</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1548</span> </span><span class="WHIT">				</span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.token</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1549</span> </span><span class="WHIT">			</span><span class="NAME">list.append</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1550</span> </span><span class="WHIT">		
<span class='line'>1551</span> 			</span><span class="NAME">stuff.append</span><span class="PUNC">(</span><span class="NAME">list</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1552</span> </span><span class="WHIT">			</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-dialog-info-session'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">stuff</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1553</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1554</span> 
<span class='line'>1555</span> </span><span class="WHIT">		</span><span class="COMM">// async load block content</span><span class="WHIT">
<span class='line'>1556</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaClient.queryDialogBuilders</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1557</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">stuff</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div />'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1558</span> </span><span class="WHIT">			</span><span class="NAME">stuff.text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-info-dialogbuilders-intro'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1559</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;ul/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-info-dialogbuilders-list'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1560</span> </span><span class="WHIT">				</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1561</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogbuilder</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1562</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;li/>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1563</span> </span><span class="WHIT">					</span><span class="NAME">item.attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-info-dialogbuilder-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1564</span> </span><span class="WHIT">					</span><span class="NAME">item.append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;tt/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-info-id'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">dialogbuilder</span><span class="PUNC">[</span><span class="STRN">'name'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1565</span> </span><span class="WHIT">					</span><span class="NAME">item.append</span><span class="PUNC">(</span><span class="NAME">sep</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1566</span> </span><span class="WHIT">					</span><span class="NAME">item.append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">dialogbuilder</span><span class="PUNC">[</span><span class="STRN">'description'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1567</span> 
<span class='line'>1568</span> </span><span class="WHIT">					</span><span class="NAME">list.append</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1569</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1570</span> </span><span class="WHIT">				</span><span class="NAME">stuff.append</span><span class="PUNC">(</span><span class="NAME">list</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1571</span> </span><span class="WHIT">				</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-dialog-info-dialogbuilders'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">stuff</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1572</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1573</span> 
<span class='line'>1574</span> </span><span class="WHIT">		</span><span class="COMM">// async load block content</span><span class="WHIT">
<span class='line'>1575</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaClient.queryProcessors</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1576</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">stuff</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;div />'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1577</span> </span><span class="WHIT">				</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">SztakipediaTB.getMsgPlaceholder</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-info-processors-intro'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1578</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;ul/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-info-processors-list'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1579</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1580</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">processor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1581</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;li/>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1582</span> </span><span class="WHIT">				</span><span class="NAME">item.attr</span><span class="PUNC">(</span><span class="STRN">'id'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-info-processors-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1583</span> </span><span class="WHIT">				</span><span class="NAME">item.append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;tt/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addClass</span><span class="PUNC">(</span><span class="STRN">'sztakipedia-info-id'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">processor</span><span class="PUNC">[</span><span class="STRN">'name'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1584</span> </span><span class="WHIT">				</span><span class="NAME">item.append</span><span class="PUNC">(</span><span class="NAME">sep</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1585</span> </span><span class="WHIT">				</span><span class="NAME">item.append</span><span class="PUNC">(</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'&lt;span/>'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="NAME">processor</span><span class="PUNC">[</span><span class="STRN">'description'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1586</span> 
<span class='line'>1587</span> </span><span class="WHIT">				</span><span class="NAME">list.append</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1588</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1589</span> </span><span class="WHIT">			</span><span class="NAME">stuff.append</span><span class="PUNC">(</span><span class="NAME">list</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1590</span> </span><span class="WHIT">			
<span class='line'>1591</span> 			</span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipedia-dialog-info-processors'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">stuff</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1592</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1593</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1594</span> 
<span class='line'>1595</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1596</span> 	 * Send the text field contents to the API for analysis.
<span class='line'>1597</span> 	 * @param {function()} callback The function to be called on completion.
<span class='line'>1598</span> 	 */</span><span class="WHIT">
<span class='line'>1599</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.updateRemoteContent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1600</span> </span><span class="WHIT">		</span><span class="COMM">// make sure user is logged in</span><span class="WHIT">
<span class='line'>1601</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">SztakipediaClient.sessionid</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1602</span> </span><span class="WHIT">			</span><span class="NAME">SztakipediaClient.newSession</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sessionid</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1603</span> </span><span class="WHIT">				</span><span class="COMM">// TODO handle error (sessionid==undefined)</span><span class="WHIT">
<span class='line'>1604</span> </span><span class="WHIT">					</span><span class="NAME">SztakipediaTB.updateRemoteContent</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// recurse</span><span class="WHIT">
<span class='line'>1605</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1606</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1607</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1608</span> 
<span class='line'>1609</span> </span><span class="WHIT">		</span><span class="COMM">// make sure a token is requested</span><span class="WHIT">
<span class='line'>1610</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.token</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1611</span> </span><span class="WHIT">			</span><span class="NAME">SztakipediaClient.newToken</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1612</span> </span><span class="WHIT">				</span><span class="COMM">// TODO handle error (token==undefined)</span><span class="WHIT">
<span class='line'>1613</span> </span><span class="WHIT">					</span><span class="NAME">SztakipediaTB.token</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1614</span> </span><span class="WHIT">					</span><span class="NAME">SztakipediaTB.updateRemoteContent</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// recurse</span><span class="WHIT">
<span class='line'>1615</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1616</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1617</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1618</span> 
<span class='line'>1619</span> </span><span class="WHIT">		</span><span class="COMM">// TODO hack to call all processors</span><span class="WHIT">
<span class='line'>1620</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaClient.update</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// TODO check for errors</span><span class="WHIT">
<span class='line'>1621</span> </span><span class="COMM">//					SztakipediaClient.buildList(function() {</span><span class="WHIT">
<span class='line'>1622</span> </span><span class="COMM">//						SztakipediaClient.buildList(function() {</span><span class="WHIT">
<span class='line'>1623</span> </span><span class="WHIT">							</span><span class="COMM">//SztakipediaClient.buildDialogs(function() {</span><span class="WHIT">
<span class='line'>1624</span> </span><span class="WHIT">								</span><span class="NAME">callback</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1625</span> </span><span class="WHIT">							</span><span class="COMM">//}, SztakipediaTB.token, 'pagelinks');</span><span class="WHIT">
<span class='line'>1626</span> </span><span class="COMM">//						}, SztakipediaTB.token, 'internallinks');</span><span class="WHIT">
<span class='line'>1627</span> </span><span class="COMM">//					}, SztakipediaTB.token, 'tokenizer');</span><span class="WHIT">
<span class='line'>1628</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.token</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1629</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1630</span> 
<span class='line'>1631</span> </span><span class="WHIT">	</span><span class="COMM">// ========================</span><span class="WHIT">
<span class='line'>1632</span> </span><span class="WHIT">	</span><span class="COMM">// STRING UTILITY FUNCTIONS</span><span class="WHIT">
<span class='line'>1633</span> </span><span class="WHIT">	</span><span class="COMM">// ========================</span><span class="WHIT">
<span class='line'>1634</span> </span><span class="WHIT">	
<span class='line'>1635</span> 	</span><span class="COMM">/**
<span class='line'>1636</span> 	 *  Returns a string quoted as necessary for name/group attributes
<span class='line'>1637</span> 	 */</span><span class="WHIT">
<span class='line'>1638</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.getQuotedString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1639</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\s/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// spaces</span><span class="WHIT">
<span class='line'>1640</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sq</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\'/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// single quotes</span><span class="WHIT">
<span class='line'>1641</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dq</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\"/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// double quotes</span><span class="WHIT">
<span class='line'>1642</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sp</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">sq</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">dq</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// No quotes necessary</span><span class="WHIT">
<span class='line'>1643</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1644</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1645</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">dq</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// Can use double quotes</span><span class="WHIT">
<span class='line'>1646</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1647</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1648</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sq</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// Can use single quotes</span><span class="WHIT">
<span class='line'>1649</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"'"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"'"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1650</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1651</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// Has double and single quotes</span><span class="WHIT">
<span class='line'>1652</span> </span><span class="WHIT">			</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\"/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'\"'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1653</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1654</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1655</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1656</span> </span><span class="WHIT">	</span><span class="COMM">// Fix up strings for output - capitalize first char, replace underscores</span><span class="WHIT">
<span class='line'>1657</span> </span><span class="WHIT">	</span><span class="COMM">// with spaces, squeeze sequences of spaces, remove leading and trailing space</span><span class="WHIT">
<span class='line'>1658</span> </span><span class="WHIT">	</span><span class="COMM">// a.k.a. wikify</span><span class="WHIT">
<span class='line'>1659</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.fixStr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1660</span> </span><span class="WHIT">		</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s.slice</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1661</span> </span><span class="WHIT">		</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/[_ ]+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1662</span> </span><span class="WHIT">		</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/^ | $/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1663</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1664</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1665</span> 
<span class='line'>1666</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1667</span> 	 *  Escape spaces and quotes for use in HTML ids or CSS classes
<span class='line'>1668</span> 	 */</span><span class="WHIT">
<span class='line'>1669</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.escStr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1670</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/[^a-zA-Z0-9_-]+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'_'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1671</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1672</span> 
<span class='line'>1673</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1674</span> 	 *  Escape regular expression special characters to be used in regexp as literal characters.
<span class='line'>1675</span> 	 */</span><span class="WHIT">
<span class='line'>1676</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.escapeRegex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1677</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">text.replace</span><span class="PUNC">(</span><span class="REGX">/[-[\]{}()*+?.,\\^$|#\s]/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"\\$&"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1678</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1679</span> </span><span class="WHIT">	
<span class='line'>1680</span> 	</span><span class="COMM">// MISC FUNCTIONS</span><span class="WHIT">
<span class='line'>1681</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1682</span> 	 *  Determine which template form is open, and get the template object for it.
<span class='line'>1683</span> 	 */</span><span class="WHIT">
<span class='line'>1684</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.getOpenTemplate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1685</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialogs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">".ui-dialog-content.ui-widget-content:visible"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1686</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">templatename</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="NAME">dialogs</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">find</span><span class="PUNC">(</span><span class="STRN">".sztakipedia-template"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1687</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">template</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1688</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.Templates</span><span class="PUNC">[</span><span class="NAME">templatename</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1689</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1690</span> </span><span class="WHIT">	
<span class='line'>1691</span> 	</span><span class="COMM">/** 
<span class='line'>1692</span> 	 * Replace a text range (e.g., after accepting a suggestion).
<span class='line'>1693</span> 	 */</span><span class="WHIT">
<span class='line'>1694</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.replaceRange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">start</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">end</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">replacement</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1695</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1696</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Invalid range."</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1697</span> </span><span class="WHIT">		
<span class='line'>1698</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1699</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">text.length</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1700</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Out of bounds."</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1701</span> </span><span class="WHIT">		</span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">start</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">replacement</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">text.slice</span><span class="PUNC">(</span><span class="NAME">end</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1702</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1703</span> </span><span class="WHIT">		</span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">change</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// to make sure a 'change' event is triggered (for Opera)</span><span class="WHIT">
<span class='line'>1704</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1705</span> 
<span class='line'>1706</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1707</span> 	 * Find the text span to be replaced in the target text field given a set of insertion strategies.
<span class='line'>1708</span> 	 * @param {Object} insertionstrategies
<span class='line'>1709</span> 	 * @param {string} [text] the string to search, defaults to the textarea contents
<span class='line'>1710</span> 	 * @return Array A two-element array containing the start and end character positions.
<span class='line'>1711</span> 	 */</span><span class="WHIT">
<span class='line'>1712</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.searchByInsertionStragtegy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">insertionstrategies</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1713</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1714</span> </span><span class="WHIT">			</span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.getTarget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1715</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1716</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1717</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'contextsensitive'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">insertionstrategies</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1718</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1719</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">insertionstrategies</span><span class="PUNC">[</span><span class="STRN">'contextsensitive'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1720</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">re</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escapeRegex</span><span class="PUNC">(</span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'before'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">')('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escapeRegex</span><span class="PUNC">(</span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'replace'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escapeRegex</span><span class="PUNC">(</span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'after'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">')'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1721</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">groups</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">re.exec</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1722</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">groups</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1723</span> </span><span class="WHIT">				</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"No match!"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1724</span> </span><span class="WHIT">			</span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">groups.index</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">groups</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1725</span> </span><span class="WHIT">			</span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">groups</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1726</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'characterpositionbased'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">insertionstrategies</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1727</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">insertionstrategies</span><span class="PUNC">[</span><span class="STRN">'characterpositionbased'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1728</span> </span><span class="WHIT">			</span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'begin'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1729</span> </span><span class="WHIT">			</span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'end'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1730</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'absolute'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">insertionstrategies</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1731</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">insertionstrategies</span><span class="PUNC">[</span><span class="STRN">'absolute'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1732</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'where'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'end'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1733</span> </span><span class="WHIT">				</span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1734</span> </span><span class="WHIT">				</span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">start</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1735</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'where'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'begin'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1736</span> </span><span class="WHIT">				</span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1737</span> </span><span class="WHIT">				</span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1738</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1739</span> </span><span class="WHIT">				</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"Unrecognized absolute position: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="PUNC">[</span><span class="STRN">'where'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1740</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1741</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1742</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"No supported insertion policy found among "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">insertionstrategies.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' (e.g., '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">insertionstrategies</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">')'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1743</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1744</span> </span><span class="WHIT">		</span><span class="COMM">// TODO implement other strategies too</span><span class="WHIT">
<span class='line'>1745</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1746</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1747</span> </span><span class="WHIT">		
<span class='line'>1748</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">start</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">end</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1749</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1750</span> 
<span class='line'>1751</span> 
<span class='line'>1752</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1753</span> 	 * Creates a RefToolbar-style template descriptor from a Sztakipedia XHTML DOM template element.
<span class='line'>1754</span> 	 * @return {Object} The resulting {@link sztakipediTemplate} object.
<span class='line'>1755</span> 	 */</span><span class="WHIT">
<span class='line'>1756</span> </span><span class="WHIT">	</span><span class="COMM">// TODO move as much as possible to SztakipediaClient</span><span class="WHIT">
<span class='line'>1757</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.addTemplateFromXhtml</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">template</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1758</span> 
<span class='line'>1759</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">title</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-title'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1760</span> 
<span class='line'>1761</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">basicFields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1762</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">expandedFields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1763</span> </span><span class="WHIT">		</span><span class="NAME">template.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-param'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">index</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1764</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">param</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1765</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">param.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-param-key'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1766</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">param.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-param-value'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1767</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">help</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">param.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-param-help'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1768</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">example</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">param.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-param-example'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1769</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hidden</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">param.hasClass</span><span class="PUNC">(</span><span class="STRN">'hidden'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1770</span> 
<span class='line'>1771</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1772</span> </span><span class="WHIT">				</span><span class="STRN">'field'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT">
<span class='line'>1773</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1774</span> </span><span class="WHIT">			</span><span class="NAME">field</span><span class="PUNC">[</span><span class="STRN">'tooltip'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">help</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1775</span> 
<span class='line'>1776</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hidden</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1777</span> </span><span class="WHIT">				</span><span class="NAME">expandedFields.push</span><span class="PUNC">(</span><span class="NAME">field</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1778</span> </span><span class="WHIT">			</span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1779</span> </span><span class="WHIT">				</span><span class="NAME">basicFields.push</span><span class="PUNC">(</span><span class="NAME">field</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1780</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1781</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">sztakipediaTemplate</span><span class="PUNC">(</span><span class="NAME">title</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">SztakipediaTB.escStr</span><span class="PUNC">(</span><span class="NAME">title</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">basicFields</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">expandedFields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1782</span> </span><span class="COMM">//		SztakipediaTB.init(); // FIXME hack, init() should not be called again</span><span class="WHIT">
<span class='line'>1783</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1784</span> </span><span class="WHIT">	
<span class='line'>1785</span> 	</span><span class="COMM">/**
<span class='line'>1786</span> 	 * Parse template title and parameters from a Sztakipedia XHTML DOM element into an object.
<span class='line'>1787</span> 	 * @param  {jQuery} template The DOM element corresponding to the template.  
<span class='line'>1788</span> 	 * @return Object
<span class='line'>1789</span> 	 */</span><span class="WHIT">
<span class='line'>1790</span> </span><span class="WHIT">	 </span><span class="COMM">// TODO move to SztakipediaClient </span><span class="WHIT">
<span class='line'>1791</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.parseTemplateFromXhtml</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">template</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1792</span> </span><span class="WHIT">		
<span class='line'>1793</span> 		</span><span class="COMM">//alert(typeof template + template);</span><span class="WHIT">
<span class='line'>1794</span> </span><span class="WHIT">		
<span class='line'>1795</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1796</span> </span><span class="WHIT">				</span><span class="STRN">'type'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'template'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1797</span> 				</span><span class="STRN">'params'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1798</span> </span><span class="WHIT">				</span><span class="STRN">'title'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1799</span> </span><span class="WHIT">				</span><span class="STRN">'multiline'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT">
<span class='line'>1800</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1801</span> </span><span class="WHIT">		</span><span class="NAME">res</span><span class="PUNC">[</span><span class="STRN">'title'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">template.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-title'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1802</span> 
<span class='line'>1803</span> </span><span class="WHIT">		</span><span class="NAME">template.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-param'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">index</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1804</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">param</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1805</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">param.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-param-key'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1806</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">param.find</span><span class="PUNC">(</span><span class="STRN">'.wiki-template-param-value'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">text</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1807</span> 
<span class='line'>1808</span> </span><span class="WHIT">			</span><span class="NAME">res</span><span class="PUNC">[</span><span class="STRN">'params'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1809</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1810</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1811</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1812</span> </span><span class="WHIT">	
<span class='line'>1813</span> 
<span class='line'>1814</span> 	</span><span class="NAME">SztakipediaTB.setTemplateDialogFields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sform</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">values</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1815</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dialog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$j</span><span class="PUNC">(</span><span class="STRN">'#sztakipediatoolbar-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sform</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1816</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">field</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">values</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1817</span> </span><span class="WHIT">			
<span class='line'>1818</span> 			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fieldid</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'sztakipedia-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sform</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">field</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// FIXME CiteToolbar could get away with this, but field names may contain spaces unsuitable for XHTML ids</span><span class="WHIT">
<span class='line'>1819</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dialog.find</span><span class="PUNC">(</span><span class="STRN">'#'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fieldid</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">val</span><span class="PUNC">(</span><span class="NAME">values</span><span class="PUNC">[</span><span class="NAME">field</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1820</span> </span><span class="WHIT">				</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"could not find field '"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fieldid</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">"'"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1821</span> </span><span class="WHIT">			</span><span class="COMM">//alert("Setting " + field + " of " + dialog.find('#' + fieldid).attr("class") + " to " + values[field]);</span><span class="WHIT">
<span class='line'>1822</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1823</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1824</span> 
<span class='line'>1825</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1826</span> 	 * Scroll to specific item.
<span class='line'>1827</span> 	 * 
<span class='line'>1828</span> 	 * @param {jQuery} scrollTo The element to show.
<span class='line'>1829</span> 	 * @param {jQuery} container The ancestor element having a scrollbar.
<span class='line'>1830</span> 	 * @param {string} [speed] Animation speed 'fast' or 'slow'. Omit for no animation.
<span class='line'>1831</span> 	 * @see http://stackoverflow.com/questions/2905867/how-to-scroll-to-specific-item-using-jquery
<span class='line'>1832</span> 	 */</span><span class="WHIT">
<span class='line'>1833</span> </span><span class="WHIT">	</span><span class="NAME">SztakipediaTB.scrollTo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">scrollTo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">container</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">speed</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1834</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">scrollHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">container.scrollTop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">scrollTo.offset</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">top</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">container.offset</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">top</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1835</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">speed</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1836</span> </span><span class="WHIT">			</span><span class="NAME">container.scrollTop</span><span class="PUNC">(</span><span class="NAME">scrollHeight</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1837</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1838</span> </span><span class="WHIT">			</span><span class="NAME">container.animate</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">scrollTop</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">scrollHeight</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">speed</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1839</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1840</span> </span><span class="WHIT">	
<span class='line'>1841</span> 
<span class='line'>1842</span> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// End of code loaded only on edit</span><span class="WHIT">
<span class='line'>1843</span> </span></pre></body></html>